zcat或gunzip:继续出错


0

当尝试gunzip或zcat大量的gzip文件时,zcat / gunzip将终止此错误:

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

有什么方法可以让gunzip或zcat继续/继续错误而不停止?这很重要,因为我们希望一些gzip文件出错,但希望我们的gunzipping操作能够在不停止和手动移动错误文件的情况下继续进行。

Answers:


2

您可以使用如下所示的shell脚本(或函数):

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

....
myzcat corrupted-or-good/*.gz >gunzipped-output.txt
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.