Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 Feb 15 '13 at 1:03

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

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

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

Your Answer


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.