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

Possible Duplicate:
What does “-” mean as an argument to a command?

When I use this command:

  tar cf - /tmp | ssh test.com tar xf -

What does the '-' mean? And is this the correct interpretation of the above command? tar the tmp directory and ssh the tarball to test.com and untar it.

share|improve this question

migrated from stackoverflow.com Mar 30 '11 at 18:19

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Michael Mrozek Mar 30 '11 at 18:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

The option -f - (i.e. the - only makes sense in conjunction with -f) tells tar to use the standard input/output instead of a filename. Which makes sense since you try to pipe the output to ssh.

Furthermore, tar allows writing shorthand options without the leading dash, which is why you (correctly) simply wrote tar f - instead of tar -f.

share|improve this answer

The "-" is a placeholder for stdout. In this case you are piping the output from the one command into the ssh session. the ssh out is piped to the remote server terminal's stdout and is again delivered to the tar command for processing.

share|improve this answer