2

In the string

wget -qO-

What exactly am I doing? I've never seen a switch that has a dash after the expression.

But, to install Docker, I am using wget -qO- https://get.docker.com | sh

8

There is nothing wrong or strange about this.

-qO- is the same as -q (quiet) followed by -O - (output to standard output).

See the wget manual.

The fact that the options are squished together is common Unix practice, and an option that takes an option-argument doesn't usually need a space in-between.

The fact that you're pulling something from the web and feeding it directly into sh should be more of a concern for you.

1

The following wget and curl commands have the same effect

wget -q -O - https://download.docker.com/linux/ubuntu/gpg

curl -fsSL https://download.docker.com/linux/ubuntu/gpg

You can run it in a Linux terminal to see the result. Basically it's output to system standout stream.

One of the practical examples of these commands are followed by | apt-key add - to add apt-key.

For example,

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
0

This is equivalent to

wget -q -O -

From man wget, here's what each option means:

-q
--quiet
    Turn of Wget's output.

-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.

Continuing the description for -O, we see that the mysterious - is just a special symbol used by the -O option to mean standard output:

If ‘-’ is used as file, documents will be printed to standard output, disabling link conversion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.