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. bzoj 4408: [Fjoi 2016]神秘数 数学 可持久化线段树 主席树

    https://www.lydsy.com/JudgeOnline/problem.php?id=4299 一个可重复数字集合S的神秘数定义为最小的不能被S的子集的和表示的正整数.例如S={1,1,1 ...

  2. 【提权思路】绕过SecureRDP限制远程连接

    工具可以在百度上下载 直接步入正题 配置好的SecureRDP是限制远程登录的用户 原理是判断来访的计算机名是否在白名单中 如果不在,便出现如上图所示 网上也有绕过方法(https://weibo.c ...

  3. [HDU6155]Subsequence Count

    题目大意: 给定一个01序列,支持以下两种操作: 1.区间反转: 2.区间求不同的子序列数量. 思路: 首先我们考虑区间反转,这是一个经典的线段树操作. 接下来考虑求不同的子序列数量,在已知当前区间的 ...

  4. opencv 利用Haar 人脸识别

    #include <opencv2/opencv.hpp> #include <cstdio> #include <cstdlib> #include <io ...

  5. flash从数据流判断图片格式防止xss攻击

    前段时间测试人员报了一个flash的xss bug,经分析用了Loader.loadBytes且没做数据流格式校验的程序都会中招,自测方法只需一行代码: ExternalInterface.call( ...

  6. iOS学习之WebView的使用 (主要是下面的全屏半透明实现)

    1.使用UIWebView加载网页 运行XCode 4.3,新建一个Single View Application,命名为WebViewDemo. 2.加载WebView 在ViewControlle ...

  7. 使用Device IO Control 讀寫 USB Mass Storage

    http://www.ezblog.idv.tw/Download/USBStorage.rar 這是一個不透過檔案系統,去讀寫USB Mass Storage 任何位置(包含FAT)的方式 首先需安 ...

  8. c#分页工具类,完美实现List分页

    using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Proje ...

  9. AES加密时抛出java.security.InvalidKeyException: Illegal key size or default parametersIllegal key size or default parameters

    使用AES加密时,当密钥大于128时,代码会抛出java.security.InvalidKeyException: Illegal key size or default parameters Il ...

  10. C#的new操作符到底做了什么

    使用new操作符来创建对象,其背后到底发生了什么? 有一个父类Animal,Dog派生于Animal. class Program { static void Main(string[] args) ...