gzipvalidationtargunzip

How to check if a Unix .tar.gz file is a valid file without uncompressing?


I have found the question How to determine if data is valid tar file without a file?, but I was wondering: is there a ready made command line solution?


Solution

  • What about just getting a listing of the tarball and throw away the output, rather than decompressing the file?

    tar -tzf my_tar.tar.gz >/dev/null
    

    Edit as per comment. Thanks Frozen Flame! This test in no way implies integrity of the data. Because it was designed as a tape archival utility most implementations of tar will allow multiple copies of the same file!