Possible Duplicate:
sudo tar cvpzf exiting with failure due to previous error
When I run the command
tar -cvfz backup.tar.gz somedirectory
I get the following sterr
tar: Exiting with failure status due to previous errors
However when I omit the preceding hyphen from -cvfz
everything seems to work just fine. Is there a known reason for why the hyphen is preventing me from tar'ing my files?
I'm not sure why
tar cvfz
works, when accourding to a quick scan of theman
page and my experience, a hyphen is standard practice. Maybe it's a BSD compatibility thing (likeps
).At any rate, your syntax is incorrect.
-f
takes the next argument as the filename to compress to. In this case, that filename isz
, which isn't what you expected. Here's a sample of the output so you can see what I mean:An
ls
shows a file calledz
. Thefile
command reveals that it's an uncompressedtar
archive. It's uncompressed because the-z
argument wasn't passed. And the error message came from trying to add the non-existant filetest.tar.gz
to the archive.Simply reorder the options and you'll be OK:
If you always make the
-f
the last argument, you'll be fine. By the way, remember that short options (one-letter options) that take arguments don't normally require a space between the option and the argument.EDIT: By the way, if the form without the hyphen is a BSD-compatibility thing or something like that, then it's likely that the way that
tar
is invoked in such an environment is different, and doesn't require thef
flag to specify the input file, but works more likecp
or something. But this is just speculation based on comparison withps
(q.v.).