zcat or gunzip: proceed on error

0

1

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.

Suman

Posted 2013-02-14T22:10:03.410

Reputation: 971

Answers

2

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

Anton Kovalenko

Posted 2013-02-14T22:10:03.410

Reputation: 296