I am trying to unzip all gz files in a certain folder. Now, I do this with a command "gunzip *.gz" in the folder. (very simple way!)
However, when an error occurs (such as, unexpected end of file), then the job is killed. I wanna just ignore such files with some problems, then continue to the next file.
How can I do this?
A simple script can skip the invalid files for you:
#!/bin/bash
for f in *.gz ; do
gunzip "$f" &> /dev/null || echo "Skipping file $f"
done
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.