不清楚curl命令-o- [英] Unclear curl command -o-
问题描述
我打算从 https:// github下载 nvm
.com / creationix / nvm ,当我偶然发现以下命令时:
I intended to download nvm
from https://github.com/creationix/nvm when I stumbled upon the following command:
curl -o- https://raw.githubusercontent .com / creationix / nvm / v0.32.1 / install.sh | bash
有人知道 -o
后面的破折号的意思吗?手册页中没有提到它,也找不到任何线索。我也尝试了不使用 -o-
选项的情况,它仍然有效,这就是为什么我想知道它的含义吗?
Does anyone know the meaning of the dash behind -o
? It isn't mentioned in the man pages, nor could I find any clue. I also tried it without the -o-
option and it still works, which is why I'm wondering what it could mean?
推荐答案
curl
的 -o
选项为您提供能够指定输出文件。在这种情况下,-
是指标准输出( stdout
),表示 curl
将输出对标准输出的响应,该输出作为
curl
's -o
option gives you the ability to specify an output file. -
in this context refers to the standard output(stdout
), which means curl
will output its response to the the standard output plugged as standard input to the bash
invocation.
在这种情况下,可以将其省略,因为输出到 curl
的标准行为是 stdout
。
In this context it could have been omitted as outputting to stdout
is curl
's standard behavior.
如 chepner 所述,当您下载多个资源时,它会变得很有用。同时希望只在 stdout
上显示其中一个:
As chepner mentions, it can become useful when you're downloading multiple ressources at the same time and want to display only one of them on stdout
:
curl -o- -o fileA -o fileB url1 url2 url3
在这种情况下 url1
将被输出到 stdout
, url2
将被输出到 fileA
和 url3
到 fileB
。
In this case url1
will be output to stdout
, url2
to fileA
and url3
to fileB
.
请注意,仍然可以避免这种情况,因为没有匹配输出规范的资源将被输出t o stdout
。以下命令的行为与上一个命令相同:
Note that this could still be avoided since ressources without a matching output specification will be output to stdout
. The following command would behave the same as the previous one :
curl -o fileA -o fileB url2 url3 url1
这篇关于不清楚curl命令-o-的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!