Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When trying to gunzip or zcat a large number of gzip files, zcat/gunzip will terminate with this error:

gzip: <gzip-file>: unexpected end of file

Is there any way I can get gunzip or zcat to continue/proceed on error without stopping? This is important since we expect some gzip files to be in error, but would like our gunzipping operation to proceed without stopping and moving the erroneous files manually.

share|improve this question

migrated from stackoverflow.com Feb 15 '13 at 1:03

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 2 down vote accepted

You can use shell script (or function) like the following:

function myzcat() {
     for file in "$@"; do
         zcat -- "$file" 2>/dev/null || true
     done
}

....
myzcat corrupted-or-good/*.gz >gunzipped-output.txt
share|improve this answer
    
Thanks! This should work, I'll test it out shortly! –  Suman Feb 14 '13 at 22:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.