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.

最新文章

  1. 破解Excel保护
  2. 【ajax】FormData
  3. MyISAM读写并发优化
  4. 20160420javaweb之文件上传和下载
  5. 12 个 CSS 高级技巧汇总
  6. Aix_bugzilla
  7. Protocol buffers--python 实践(一) 简介以及安装与使用
  8. TF-IDF学习(python实现)
  9. 获取Shell脚本当前的目录
  10. 流程控制之for
  11. pip离线安装python包
  12. 第8章 用SQL语句操作数据
  13. tcpcopy真实流量压测工具
  14. mysql 内存表
  15. Servlet学习(二):ServletConfig获取参数;ServletContext应用:请求转发,参数获取,资源读取;类装载器读取文件
  16. 转载-MyBatis学习总结
  17. 使用DbTableColumnWeb项目简要
  18. 从win10家庭版/中文版升级到win10专业版
  19. Xshell和Xftp5配置连接阿里云服务器
  20. 20155311高梓云补交的Mypc课下实践

热门文章

  1. [ 转载 ] Java基础4--Java中的static关键字解析
  2. JZYZOJ 2002 [cf] 石江豪pk李震 博弈论 sg函数
  3. java的反射机制(第三篇)
  4. java后台接收json数据,报错com.alibaba.fastjson.JSONObject cannot be cast to xxx
  5. HDU 5154 Harry and Magical Computer bfs
  6. git一些命令
  7. DeJaVu update history
  8. Running multiple instances of Xamarin Studio on a Mac
  9. Unity3.x游戏开发经典教程 书例 100%完毕~
  10. cocos编译Android版本号问题总结