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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With