mytry
V2EX  ›  程序员

curl 命令参数 `-o-` 有什么意义?

By mytry at 2019 年 5 月 17 日 · 6319 次点击

看见 nodejs nvm 的安装命令: https://github.com/nvm-sh/nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

or Wget:

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

curl 的 -o 是输出到某个文件,-o- 是输出到 stdout 吗,这和不加任何参数有什么区别? wget 倒是可以理解,因为它默认是输出到文件的。

(另外,看到很多程序远程安装都提供 curl 和 wget 两个版本,是不是有些系统默认不支持 curl 或者不好用?)

6 条回复  •  2019-07-09 14:08:19 +08:00
neroxps
   1
neroxps  
   2019 年 5 月 17 日
busybox 默认只有 wget
trn4
   2
trn4  
   2019 年 5 月 17 日
-o-就是输出到 stdout。
有的系统既没有 wget,也没有 curl ……
CSM
   3
CSM  
   2019 年 5 月 17 日 via Android
内容是二进制文件时,curl 会提示你为了不搞乱终端,截断了输出之类的,所以需要显式指定。
但是输出重定向不就不会有这个提示了,所以我猜是 -o- 看起来很萌?( ̄▽ ̄)
ly50247
   4
ly50247  
   2019 年 5 月 17 日
在这里加不加 -o- 没什么区别。
AsisA
   5
AsisA  
   2019 年 5 月 17 日
应该是大写的 O 吧,大写 -O- 会输出到 stdout
no1xsyzy
   6
no1xsyzy  
   2019 年 7 月 9 日
https://github.com/curl/curl/blob/92963d612b9c5ef32d63d26c72d6fff64930eba6/src/tool_operate.c#L818

config->terminal_binary_ok = (outfile && !strcmp(outfile, "-"));

"-" 有区别的地方就这一个,所以应该如 #3 所说。
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
© 2026 V2EX · 442ms · 3.9.8.5