What's the function of wget's -O -?
Sophia Terry
I see some linux page says how to install the key:
wget -O - | sudo apt-key add -What is "-O -" in wget?
It seems related with "add -".
How these works?
Thank you~
12 Answers
I used ** to indicate it is important.
from man wget
-O file --output-document=file The documents will not be written to the appropriate files, but all will be concatenated together and written to file. ** If - is used as file, documents will be printed to standard output, disabling link conversion. (Use ./- to print to a file literally named -.) ** Use of -O is not intended to mean simply "use the name file instead of the one in the URL;" rather, it is analogous to shell redirection: wget -O file is intended to work like wget -O - > file; file will be truncated immediately, and all downloaded content will be written there.and from man apt-key
add filename Add a new key to the list of trusted keys. The key is read from filename, or ** standard input if filename is -.**this explains your command.
The option -O - prints the downloaded file to standard output (instead of a ordinary file) and the - option in apt-key reads from standard input. The command is equivalent to the two commands:
wget
sudo apt-key add ros.keyWhen you chain both commands you don't have to bother with saving a file and usually the command is shorter.