What's the difference between - (one hyphen) and — (two hyphens) in a command?
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.
---------------------------------------------------------
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 s
, p
, a
, m
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?的更多相关文章
- SQL injection
SQL injection is a code injection technique, used to attack data-driven applications, in which malic ...
- Git - Tutorial [Lars Vogel]
From: http://www.vogella.com/tutorials/Git/article.html Git - Tutorial Lars Vogel Version 5.6 Copyri ...
- Git - Tutorial官方【转】
转自:http://www.vogella.com/tutorials/Git/article.html#git_rename_branch Lars Vogel Version 5.8 Copyri ...
- 关于php文件读取的一些学习记录
初学PHP的时候使用了一些文件读取API,但是没有真正弄清楚各API的区别以及差异,于是找了一篇学习了一下,贴在这里,引用自IBM社区的一篇文章, 整体整理测试如下 <?php /** * Cr ...
- 向Docx4j生成的word文档中添加布局--第二部分
原文标题:Adding layout to your Docx4j-generated word documents, part 2 原文链接:http://blog.iprofs.nl/2012/1 ...
- MySQL之mysql命令使用详解
MySQL Name mysql - the MySQL command-line tool Synopsis mysql [options] db_name Description mysql is ...
- 批量删除linux的文件;find方法批量删除文件;find查找某时间段内的所有文件
1.如图所示,有大量文件夹,想批量删除它们 2.使用命令 find . -maxdepth 1 -regex ".*ws.*" 可以批量找到他们.maxdepth值为1表示只在当 ...
- su with hyphen and without - su带横杠和不带横杠
The difference between "-" and "no hyphen" is that the latter keeps your existin ...
- Java 堆内存与栈内存异同(Java Heap Memory vs Stack Memory Difference)
--reference Java Heap Memory vs Stack Memory Difference 在数据结构中,堆和栈可以说是两种最基础的数据结构,而Java中的栈内存空间和堆内存空间有 ...
随机推荐
- 解读socketserver之Tcpserver
在解析socketserver是如工作之前,我们先看看socektserver类的继承关系图: 请求类继承关系: server类继承关系: 有了上面的继承关系图后,我们解析socketserver就轻 ...
- PHP5.3以上版本使用pthreads PHP扩展真正支持多线程
class test_thread_run extends Thread{public $url;public $data; public function __construct($url){$th ...
- 【对比分析三】CSS中 link 和@import 的区别
1). link 是 XHTML 标签,无兼容问题: @import 是在 CSS2.1 提出的,只有IE5以上才能识别. 2). 语法结构不同. link (链接式)只能放入HTML源码中,语法 ...
- List常用子类的特点
ArrayList: 底层数据结构是数组,查询快,增删慢 线程不安全, 效率较高 Vector 底层数据结构是数组,查询快,增删慢 线程安全, 效率较低 LinkedList 底 ...
- Windows下openssl安装及使用
配置过程中需要生成一些mak文件,这些生成代码用perl脚本生成,所以要安装一个ActivePerl. 网址: http://www.activestate.com/activeperl/ 下载后直接 ...
- python学习笔记5.1-核心类型-集合set类型[转]
转自:http://blog.csdn.net/business122/article/details/7541486 python的set和其他语言类似, 是一个无序不重复元素集, 基本功能包括关系 ...
- Win8开机直接进桌面方法
最新的Win8系统由于新增开始屏幕(UI)界面,专门为触摸设备准备,并且很多喜欢尝鲜的电脑爱好者朋友在我们传统的电脑上安装了Win8系统,不少PC用户开始都不喜欢Win8开机后进入UI界面而非传统的电 ...
- TransactionScope只要一个操作失败,它会自动回滚,Complete表示事务完成
实事上,一个错误的理解就是Complete()方法是提交事务的,这是错误的,事实上,它的作用的表示本事务完成,它一般放在try{}的结尾处,不用判断前台操作是否成功,如果不成功,它会自己回滚. #re ...
- 在Powerdesigner中创建概念数据模型
点击菜单“File”---->“New Model” 点击[OK]按钮后,将进入如下的画面 系统将出现一个工具栏如下,用于在设计面板中设计模型
- 关于TFS2010 远程无法创建团队项目的若干问题总结
今天遇到一个TFS的问题,折腾了好几个小时,故将其记录,给有遇到类似问题的朋友一些参考. 1.本文前提:服务器端只安装了TFS2010,本地没有安装Visual Studio 2010,因此不能在服务 ...