tar exits on "Cannot stat: No such file of directory", why?
I'm trying to create tar.gz file using the following command:
sudo tar -vcfz dvr_rdk_v1.tar.gz dvr_rdk/
It then start to create files (many files in folder), but then I get the following error:
tar: dvr_rdk_v1.tar.gz: Cannot stat: No such file or directory tar: Exiting with failure status due to previous errors
I don't see any description of this error, what does it mean?
tardoes not need hyphen for options.
With a hyphen, the argument for the
z. So the command is in effect trying to archive
dvr_rdkinto an archive called
z. Without the hyphen, the semantics of the options changes, so that the next argument on the command line, i.e. your archive's filename, becomes the argument to the
Also check your write permission to the directory from which you are executing the command.
It doesn't *need* hyphens, but they shouldn't be a problem, they're just optional
@MichaelMrozek Actually, removing the `-` does make a difference, because GNU tar is quirky. Option arguments can't be bundled in the first argument when it doesn't start with a `-`, so the argument to `f` is the next argument to `tar`, and so `tar vcfz dvr_rdk_v1.tar.gz` is equivalent to `tar -v -c -f dvr_rdk_v1.tar.gz -z`.
I also realized if I remove the `z` or `j` the archive compression is successful even with `-` involved. When I add the hyphen is included it treats the last character in the option as a "file". So as a result I get `j` or `z` as an archived file if I use this option `-cvfz` or `-cvfj`.
**Summary:** if 'f' occurs as an option anywhere other as than the last option, then the command will not do what was intended. I don't see how Gnu couldn't add a warning when they detect such a serious and easily-detectable issue. I just spent 40min trying to debug this weirdness. This one must have wasted hundreds of thousands of man-hours of productivity.