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.

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.

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

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


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.


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.