Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

up vote 4 down vote accepted

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

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

share|improve this answer
    
thanks, you're right. I just removed the "-", and it works. –  ransh Aug 10 at 10:18
1  
It doesn't need hyphens, but they shouldn't be a problem, they're just optional –  Michael Mrozek Aug 10 at 19:00
2  
@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. –  Gilles Aug 10 at 22:19

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

share|improve this answer

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/
share|improve this answer

To create the archive

$ tar -cvf music.tar Music/

This shows the list of file & folders

$ tar -tvf music.tar         

And to extract again

$ tar -xvf music.tar         
share|improve this answer
    
This does not really explain his error, right? This is just explaining the usage of tar. –  Bernhard Aug 10 at 8:23
1  
@Bernhard Well, his error was that he was using tar wrong, although it's nice to at least mention what the key difference is (moving -f to the end) –  Michael Mrozek Aug 10 at 19:01
2  
@MichaelMrozek Well, he rather left out the z than put f in the end, hence my comment. –  Bernhard Aug 10 at 19:06
    
This command working for ubuntu, It will success –  dhamu Sep 6 at 13:23
    
OK! sorry, I am not listening you question, but the command working for ubuntu. –  dhamu Sep 6 at 13:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.