If you want to make a real test extract of the tar file without extracting it to disk, use the -O option. This selects the extract to standard output instead of the file system. If the tar file is damaged, the process will be aborted with an error.
An example of a failed ball test ...
$ echo "this will not pass the test" > hello.tgz $ tar -xvzf hello.tgz -O > /dev/null gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error exit delayed from previous errors $ rm hello.*
Working example ...
$ ls hello* ls: hello*: No such file or directory $ echo "hello1" > hello1.txt $ echo "hello2" > hello2.txt $ tar -cvzf hello.tgz hello[12].txt hello1.txt hello2.txt $ rm hello[12].txt $ ls hello* hello.tgz $ tar -xvzf hello.tgz -O hello1.txt hello1 hello2.txt hello2 $ ls hello* hello.tgz $ tar -xvzf hello.tgz hello1.txt hello2.txt $ ls hello* hello1.txt hello2.txt hello.tgz $ rm hello*
Ossie Moore Jan 17 '12 at 19:41 2012-01-17 19:41
source share