Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I found this link on how to open tgz in one step.

gzip -dc target.tar.gz | tar xf -

What does the '-' mean?

share|improve this question
Also, most versions of tar now support gzip and bzip natively. For a gzip-ed tar file tar xfz target.tar.gz and for bzip tar xfj target.tar.bz2 – Deleted Account Mar 16 '11 at 23:04
up vote 18 down vote accepted

It's a common convention to use - in a filename argument to mean stdin or stdout; tar follows the same convention. From the man page:

   -f, --file [HOSTNAME:]F
          use archive file or device F (default "-", meaning stdin/stdout)
share|improve this answer
This is only a convention; you need to read the manpage for the particular command to see what - means to it. Stdin/stdout is by far the most common meaning, but there are others. For instance, to some versions of env it means "start with an empty environment". – cjm Mar 16 '11 at 23:05

Another convention is to use '-' to indicate the end of flags, and the beginning of file names. That behavior is built-in to the getopt(3) on RedHat 4, at least. I can't find a Red Hat man page that uses '-' to indicate end-of-arguments, they all seem to use '--' to do that. The awk man page has '--' in that context, so maybe only old "heirloom" Unix or Solaris commands use '-' as a arguments - file names separator.

share|improve this answer
-- signals the end of options, so everything that comes afterwards is an operand. - is not an option, so it and everything that comes afterwards is an operand. This is standard behavior. For many commands, such as tar, the operand - means standard input or output. On many shells, set - -a is equivalent to set -- -a, and on some old Bourne shells set - -a was the only accepted form, but this an exception with the set built-in. – Gilles Mar 16 '11 at 22:37
Solaris programs mainly follow the POSIX standard convention of -- to separate options from arguments. – alanc Jul 30 '11 at 7:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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