What does the hyphen "-" mean in "tar xzf -"?

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?


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.


That's just a filename that a lot of Unix programs interpret as "instead of actually opening a file, read from stdin (or write to stdout)."

That means reading from the input that gets streamed into the program; in your case, that's the output of wget.


The - argument to tar specifies that the archive should be read from stdin instead of a file. From the GNU tar manual:

If you use - as an archive-name, tar reads the archive from standard input (when listing or extracting files)

Other commands have the same behavior, and it is specified by the POSIX.1-2017 standard:

Guideline 13:

For utilities that use operands to represent files to be opened for either reading or writing, the '-' operand should be used to mean only standard input (or standard output when it is clear from context that an output file is being specified) or a file named -.