What's the difference between - (one hyphen) and — (two hyphens) in a command?
2024-08-28 05:30:33
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.
最新文章
- 破解Excel保护
- 【ajax】FormData
- MyISAM读写并发优化
- 20160420javaweb之文件上传和下载
- 12 个 CSS 高级技巧汇总
- Aix_bugzilla
- Protocol buffers--python 实践(一) 简介以及安装与使用
- TF-IDF学习(python实现)
- 获取Shell脚本当前的目录
- 流程控制之for
- pip离线安装python包
- 第8章 用SQL语句操作数据
- tcpcopy真实流量压测工具
- mysql 内存表
- Servlet学习(二):ServletConfig获取参数;ServletContext应用:请求转发,参数获取,资源读取;类装载器读取文件
- 转载-MyBatis学习总结
- 使用DbTableColumnWeb项目简要
- 从win10家庭版/中文版升级到win10专业版
- Xshell和Xftp5配置连接阿里云服务器
- 20155311高梓云补交的Mypc课下实践
热门文章
- [ 转载 ] Java基础4--Java中的static关键字解析
- JZYZOJ 2002 [cf] 石江豪pk李震 博弈论 sg函数
- java的反射机制(第三篇)
- java后台接收json数据,报错com.alibaba.fastjson.JSONObject cannot be cast to xxx
- HDU 5154 Harry and Magical Computer bfs
- git一些命令
- DeJaVu update history
- Running multiple instances of Xamarin Studio on a Mac
- Unity3.x游戏开发经典教程 书例 100%完毕~
- cocos编译Android版本号问题总结