Recover a corrupted gz

Writing by on Wednesday, 14 of October , 2015 at 7:13 am

Sometimes you might be able to salvage a corrupted gzip. Typically this trick always works on most log files.

$ gunzip corrupted.gz
gunzip: corrupted.gz: unexpected end of file
gunzip: corrupted.gz: uncompress failed

Use the -c option that outputs to console, but redirect to a new salvaged file. Then gzip the salvaged file to recover it.

$ gunzip -c corrupted.gz > salvaged
$ gzip salvaged

You can now delete the corrupted gz file and use the salvaged version.

Leave a comment

Category: Linux,Tips and Tricks

No Comments

No comments yet.

Leave a comment

You must be logged in to post a comment.

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.