Jabb Jabb - 4 months ago 16
Linux Question

Gunzip multiple files in folder and continue on error

I am unzipping multiple files in a folder like this:

gunzip -f -k *.gz


Some of the .gz files are broken which cause the command to abort.

What is a nice way of unzipping all files while ignoring the broken ones?

Answer

Use this loop as suggested by @Gene

for file in `*.gz`
do
   gunzip -f -k $file
done