不明确的卷曲命令-o-

eol*_*eol 9 bash curl

当我偶然发现以下命令时,我打算nvmhttps://github.com/creationix/nvm下载:

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

有谁知道后面的破折号的含义-o?在手册页中没有提到它,我也找不到任何线索.我也尝试了它没有-o-选项,它仍然有效,这就是为什么我想知道它可能意味着什么?

Aar*_*ron 10

curl-o选项使您能够指定输出文件.-在此上下文中引用标准输出(stdout),这意味着curl将其响应输出到作为bash调用的标准输入插入的标准输出.

在这种情况下它可能已被作为输出到省略stdoutIS curl的标准行为.

正如chepner所提到的,当你同时下载多个资源并希望只显示其中一个时,它会变得很有用stdout:

curl -o- -o fileA -o fileB url1 url2 url3
Run Code Online (Sandbox Code Playgroud)

在这种情况下url1将输出到stdout,url2fileAurl3fileB.

请注意,这仍然可以避免,因为将输出没有匹配输出规范的资源stdout.以下命令的行为与前一个相同:

curl -o fileA -o fileB url2 url3 url1
Run Code Online (Sandbox Code Playgroud)