How can I quickly check if a gzipped file is valid?

0
6
Asked By MerryCat123 On

I have a .tgz file and want to make sure that it downloaded completely without any issues. Running `tar -tzf foo.tgz > /dev/null` takes about 30 seconds, which is a bit too long for my needs. I've heard that gzipped files have specific bytes at the end that indicate their validity. Is there a faster method, perhaps by checking the final bytes or using another command?

4 Answers

Answered By CuriousRaccoon789 On

If you have a checksum for the file, that's the best way to ensure that your download matches what's expected. It guarantees the integrity of the file.

Answered By FunnyClam456 On

You can use `gzip -t foo.tgz` to quickly check if the gzip part of the file is valid. This should be much quicker than running a full `tar` test.

Answered By SillyPenguin423 On

I tried a method where I truncated a file using: `cat a_random_tgz_in_my_home.tgz | head -c -1000 > defect.tgz` then ran `tar tf defect.tgz`. It resulted in 'Unexpected EOF in archive,' indicating not all the data is there.

Answered By WiseOwl321 On

Using checksums is really the best practice here. They help confirm that the file you downloaded is exactly what the original creator intended, avoiding issues with corrupted downloads.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.