Can someone help me understand this command:
tar -czf - -T ./tarFileList.tmp -C ./test_folder/ | ssh -l musthero voserver95.myserver.com -x "umask 002; cd /disk0/test_untar/ ; tar -xzf - "
In particular, I can't understand what is the first dash for (tar -czf - ...
).Why do I need it if I have specified list of files I would like to tar (i.e. -T ./tarFileList.tmp
), and a directory where to take those files from (i.e. -C ./test_folder/
).
Also copying is a bit confusing too - how the tarball gets copied over ssh if there is no cp/scp
command?
The very first dash is unnecessary, you could equally write:
tar cvf ...
The second dash belongs with the f
option and it says "instead of creating a named file in the filesystem, write the tarred up files onto stdout
".
That stdout
is then passed through the pipe into ssh
. The corresponding untar on the remote machine is untarring from its stdin
in exactly the same way.
So, in answer to your question, the dashes mean stdout
when creating/writing a tarfile with tar cf
and stdin
when extracting/reading a tarfile with tar xf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With