bash中看到这样的命令,

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs 黄色部分,| 这个是管道操作符,表示前面命令的输出作为后面的命令的输入。 "bash -" bash 跟一个短杠的作用是什么呢?
For a command, if using - as an argument in place of a file name will mean STDIN or STDOUT.

参考:https://askubuntu.com/questions/813303/whats-the-difference-between-one-hyphen-and-two-hyphens-in-a-command

---------------------------------------------------------

Generally:

  • - means to read the argument/content from STDIN (file descriptor 0)

  • -- means end of command options, everything follows that are arguments

Why needed:

About -:

$ echo foobar | cat -
foobar

Although cat can read content from STDIN without needing the -, many commands need that and their man pages mention that explicitly.

Now about --, I have created a file -spam, let's cat the file:

$ echo foobar >-spam  

$ cat -spam
cat: invalid option -- 'p'
Try 'cat --help' for more information. $ cat -- -spam
foobar

Without --cat takes spam all as it's options as they follow --- explicitly indicates the end of option(s), after that -spam is taken as a file name.

What's the difference between - (one hyphen) and — (two hyphens) in a command?的更多相关文章

  1. SQL injection

    SQL injection is a code injection technique, used to attack data-driven applications, in which malic ...

  2. Git - Tutorial [Lars Vogel]

    From: http://www.vogella.com/tutorials/Git/article.html Git - Tutorial Lars Vogel Version 5.6 Copyri ...

  3. Git - Tutorial官方【转】

    转自:http://www.vogella.com/tutorials/Git/article.html#git_rename_branch Lars Vogel Version 5.8 Copyri ...

  4. 关于php文件读取的一些学习记录

    初学PHP的时候使用了一些文件读取API,但是没有真正弄清楚各API的区别以及差异,于是找了一篇学习了一下,贴在这里,引用自IBM社区的一篇文章, 整体整理测试如下 <?php /** * Cr ...

  5. 向Docx4j生成的word文档中添加布局--第二部分

    原文标题:Adding layout to your Docx4j-generated word documents, part 2 原文链接:http://blog.iprofs.nl/2012/1 ...

  6. MySQL之mysql命令使用详解

    MySQL Name mysql - the MySQL command-line tool Synopsis mysql [options] db_name Description mysql is ...

  7. 批量删除linux的文件;find方法批量删除文件;find查找某时间段内的所有文件

    1.如图所示,有大量文件夹,想批量删除它们 2.使用命令 find . -maxdepth 1  -regex ".*ws.*" 可以批量找到他们.maxdepth值为1表示只在当 ...

  8. su with hyphen and without - su带横杠和不带横杠

    The difference between "-" and "no hyphen" is that the latter keeps your existin ...

  9. Java 堆内存与栈内存异同(Java Heap Memory vs Stack Memory Difference)

    --reference Java Heap Memory vs Stack Memory Difference 在数据结构中,堆和栈可以说是两种最基础的数据结构,而Java中的栈内存空间和堆内存空间有 ...

随机推荐

  1. dSploitzANTI渗透教程之HTTP服务重定向地址

    dSploitzANTI渗透教程之HTTP服务重定向地址 HTTP服务 HTTP服务主要用于重定向地址的.当用户创建一个钓鱼网站时,可以通过使用HTTP服务指定,并通过实施中间人攻击,使客户端访问该钓 ...

  2. tftp协议

    <前言> 嵌入式开发是一个交叉开发的模式,需要将宿主机上的文件烧写到目标机上. 方式: JTAG USB 串口 网络 <tftp下载> 首先需要将宿主机架成一个TFTP的服务器 ...

  3. DataTable,List,Dictonary互转,筛选及相关写法

    1.创建自定义DataTable  /// 创建自定义DataTable(一) 根据列名字符串数组, /// </summary> /// <param name="sLi ...

  4. Struts2 (下)

    接收参数 当发送一个请求时,除了使用RequestApi来接收参数之外,Struts2内部提供了3种接收参数的方式 接收参数的方式 1. 提供属性set方法的方式 在Action当中提供对应属性的se ...

  5. 【推导】【数学期望】【冒泡排序】Petrozavodsk Winter Training Camp 2018 Day 5: Grand Prix of Korea, Sunday, February 4, 2018 Problem C. Earthquake

    题意:两地之间有n条不相交路径,第i条路径由a[i]座桥组成,每座桥有一个损坏概率,让你确定一个对所有桥的检测顺序,使得检测所需的总期望次数最小. 首先,显然检测的时候,是一条路径一条路径地检测,跳跃 ...

  6. Problem H: 深入浅出学算法009-韩信点兵

    Description 秦朝末年,楚汉相争.有一次,韩信将1500名将士与楚王大将李锋交战.苦战一场,楚军不敌,败退回营,汉军也死伤四五百人,于是,韩信整顿兵马也返回大本营.当行至一山坡,忽有后军来报 ...

  7. 【洛谷】4917:天守阁的地板【欧拉函数的应用】【lcm与gcd】【同除根号优化】

    P4917 天守阁的地板 题目背景 在下克上异变中,博丽灵梦为了找到异变的源头,一路打到了天守阁 异变主谋鬼人正邪为了迎击,将天守阁反复颠倒过来,而年久失修的天守阁也因此掉下了很多块地板 异变结束后, ...

  8. 计算机二级软件VC++6.0下载地址

    计算机二级软件VC++6.0介绍: 适合所有参加全国计算机等级考试的童鞋们……见图如下: 下载地址:(以下两者任选其一即可) (1).计算机二级软件VC++6.0(16.35MB) (2).计算机二级 ...

  9. PYQT设计无边框窗体

    #UI.py,通过UI设计师制作后直接转换为UI.py脚本 # -*- coding: utf-8 -*-from PyQt4 import QtCore, QtGui try:    _fromUt ...

  10. SQL(insert、delete、update)执行成功,但是数据库表中无显示无记录

    如题,程序中insert一条记录,调试过程中根据执行结果发现此条sql已经执行成功(影响行数为1且插入记录已生成自增主键正确值),但是查询数据库相应表时发现表中并无相应记录,通过直接在表中插入测试数据 ...