I tried tar with xvfz and -xvfc both didn’t work in Cygwin on Windows.
$ tar xvfz sshpass-1.0.5.tar.gz tar (child): sshpass-1.0.5.tar.gz: Cannot open: No such file or directory tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error is not recoverable: exiting now
Here cmd tar with ‘-‘
$ tar -xvfz sshpass-1.0.5.tar.gz tar: z: Cannot open: No such file or directory tar: Error is not recoverable: exiting now
Question :
1 . How does tar works with -
or without _
?
Please suggest to execute tar -xvfz sshpass-1.0.5.tar.gz.
Advertisement
Answer
tar has 3 types of syntax (according to this ):
long options (–file) short options (-f) old options (f) For the old option syntax, all the letters must follow “tar” and must all fall into a single clump with no spaces. The order of the letters doesn’t really matter, so long as the arguments to those letters follow the same order after the clump of options.
This old way of writing tar options can surprise even experienced users. For example, the two commands:
# tar cfz sshpass-1.0.5.tar.gz file # tar -cfz sshpass-1.0.5.tar.gz file
are quite different. The first example uses ‘sshpass-1.0.5.tar.gz’ as the value for option ‘f’ and recognizes the option ‘z’. The second example, however, uses ‘z’ as the value for option ‘f’ — probably not what was intended.
Old options are kept for compatibility with old versions of tar.
The command with a ‘-‘ is equivalent to
tar -czf sshpass-1.0.5.tar.gz file tar -cf sshpass-1.0.5.tar.gz -z file tar cf sshpass-1.0.5.tar.gz -z file