Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that you can do -W when creating an archive, but how do you verify and already-created archive? tvWf says it's not a valid tar archive?

$ mkdir tmp
$ echo asdkfjh > tmp/a
$ echo qweroiu > tmp/b
$ ls
$ tar cvf archive.tar tmp
$ tar tvWf archive.tar
tar: This does not look like a tar archive
tar: Skipping to next header
tar: VERIFY FAILURE: 1 invalid header detected
tar: Error exit delayed from previous errors

Same thing happens with both tar 1.15 (which is the system default on centos 5) and 1.26 (which is the newest version from gnu).

share|improve this question
up vote 5 down vote accepted

You can't use W with t.

mkdir tmp
echo bdb > tmp/a
echo bdb > tmp/b

tar cvf archive.tar tmp

ls -l archive.tar
-rw-r--r-- 1 tony tony 10240 Jun 23 05:57 archive.tar

tar tvf archive.tar
drwxr-sr-x tony/tony         0 2011-06-23 05:57 tmp/
-rw-r--r-- tony/tony         4 2011-06-23 05:57 tmp/a
-rw-r--r-- tony/tony         4 2011-06-23 05:57 tmp/b

tar tvWf archive.tar
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors

I believe t alone is enough to test the archive.

share|improve this answer
t alone just lists the content of the archive. I want to verify that the files in the tar have the same contents as the originals (still on the file system), which I thought was what W should do (right?). – cespinoza Jun 23 '11 at 22:01
W does that only when writing the archive. If you want to make sure the content is a byte for byte match you'll have to extract it somewhere and diff/sum the files. – EightBitTony Jun 23 '11 at 22:29

GNU tar has a --compare option. See the Comparing Archive Members with the File System section of the documentation for details.

share|improve this answer

Joerg Schillings star sports a diff option, which is able to compare files in a tar archive with their original. You can state what should be recognized as difference.

0 1 newt pts/1 ~ 17> :> tmp/testfile
0 1 newt pts/1 ~ 19> star -cz tmp > tmp.tar
0 1 newt pts/1 ~ 19> echo bla > tmp/testfile
0 1 newt pts/1 ~ 20> star -z -diff diffopts=not,times < tmp.tar
tmp/testfile: different size,data
star: 115 blocks + 0 bytes (total of 1177600 bytes = 1150.00k).

Note that it mentioned testfile as being of different size and data. If I hadn't excluded times (including access time!) it would have stated the access time as well, and also list all files whose times had changed just by looking at them.

star can be found at [Berlios][1], or at the [ftp path for current version 1.5.1][2]. Its highly portable, and compiles painlesslz on most unixoid systems and unixoid look-alikes.
share|improve this answer

Your Answer


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.