tar exits on "Cannot stat: No such file of directory", why?

Remove - from vcfz options. tar does not need hyphen for options.

With a hyphen, the argument for the -f option is z. So the command is in effect trying to archive dvr_rdk_v1.tar.gz and dvr_rdk into 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 f flag.

Also check your write permission to the directory from which you are executing the command.


The -f option should directly precede the filename. So, use tar -vczf filename.tar.gz instead of -vcfz


The tar command historically has been one of the few commands that doesn't follow the Unix utility syntax guidelines.

The standards page for tar says:

f
Use the first file operand (or the second, if b has already been specified) as the name of the archive instead of the system-dependent default

While the syntax guidelines include this:

Guideline 5:
One or more options without option-arguments, followed by at most one option that takes an option-argument, should be accepted when grouped behind one '-' delimiter.

So while the command you typed, tar -vcfz dvr_rdk_v1.tar.gz dvr_rdk/, would be fine on older versions of tar, certain versions of tar that are written to strictly follow the utility syntax guidelines will parse this to mean "use z as the file argument to -f". So you should use the following to be portable:

tar -cvzf dvr_rdk_v1.tar.gz dvr_rdk/

Tags:

Tar