how to check/validate the tar.gz files before un-tar

9,045

Importing from stackoverflow user John Boker's answer, one can do it in several ways:

  1. To test the gzip file is not corrupt:

    gunzip -t file.tar.gz
    
  2. To test the tar file inside is not corrupt:

    gunzip -c file.tar.gz | tar t > /dev/null
    
Share:
9,045

Related videos on Youtube

yael
Author by

yael

Updated on September 18, 2022

Comments

  • yael
    yael over 1 year

    when we uncompressed tar.gz file with tar xfz

    tar xfz redhatPkgInstallation.tar.gz 
    

    we get the following errors

    gzip: stdin: decompression OK, trailing garbage ignored
    tar: Child returned status 2
    tar: Error is not recoverable: exiting now
    failed while , error 2
    

    is it possible to check tar.gz files propriety before we untar the file?

    goal - check/validate the tar.gz file before un-tar ,

  • Vishnu Kumar
    Vishnu Kumar about 4 years
    bunzip2 -t file.tar.gz if you used bzip2