Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unclear curl command -o-

Tags:

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

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?

like image 333
eol Avatar asked Nov 09 '16 14:11

eol


1 Answers

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.

In this context it could have been omitted as outputting to stdout is curl's standard behavior.

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

In this case url1 will be output to stdout, url2 to fileA and url3 to fileB.

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
like image 171
Aaron Avatar answered Nov 11 '22 04:11

Aaron