Ubuntu – What does the hyphen “-” mean in “tar xzf -”

command linetar

When try to install dropbox from command line, I read the commands

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -

what does - mean here? is it previous directory?

Best Answer

Some commands accept - in place of a filename, either:

  • To write to standard output instead of to a named file. This is what the - argument passed to wget after -O is doing.
  • To read from standard input instead of from a named file. This is what the - argument passed to tar after xzf.

The command you showed downloads an archive file with wget and unpacks it with tar. To achieve this, the output of wget is piped (|) to the input of tar. This is why wget writes to standard output instead of a file and tar reads from standard input instead of a file.