Shell script to verify zip archives

This is similar to my little shell one liner to verify tar archives. Exit status of 0 means the archive is good, anything else means there's a problem. Most of the problem archives I encountered had a status of 2, but a few 3's and 9's as well -- see "man unzip" for explanation of status codes. Using a while loop because some of the archive files names have spaces in them, which trips up the for loop:

find . -name "*.zip" | while read f; do unzip -t "$f" &> /dev/null; err="$?"; echo checking "$f"; echo $err "$f" >> zip-check.list; done


2 ./1-02-cv-00319-RHB-JGS(170).zip
0 ./1-02-cv-00319-RHB-JGS(171).zip
2 ./1-02-cv-00319-RHB-JGS(172).zip
2 ./1-02-cv-00319-RHB-JGS(173).zip
0 ./1-02-cv-00319-RHB-JGS(174).zip
2 ./1-02-cv-00319-RHB-JGS(175).zip
0 ./1-02-cv-00319-RHB-JGS(176).zip
0 ./1-02-cv-00319-RHB-JGS(177).zip
2 ./1-02-cv-00319-RHB-JGS(178).zip
0 ./1-02-cv-00319-RHB-JGS(179).zip

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).