How can I check CRC from multiple zip files with zip -T

I have a bash script to check CRC of multiple ZIP files:

#! /bin/bash

fileFormat="*.zip"

for entry in `ls $fileFormat`; do
    echo $entry >> plikiZip
done

fileName=$(< plikiZip)

for file in "${fileName[@]}"; do
        zip -T $file >> wynik.txt
done

      

I don't know why, byt my wynik.txt contains:

  adding: mf.gov.pl_1133863230349.zip (stored 0%)
  adding: mf.gov.pl_1133863293588.zip (stored 0%)
  adding: mf.gov.pl_1133863748942.zip (stored 0%)
  adding: noweprzetargi.msgaz.pl_1133848724906.zip (stored 0%)
  adding: swps.pl_1133864085863.zip (stored 0%)
  adding: swps.pl_1133864308647.zip (stored 0%)
  adding: swps.pl_1133864438352.zip (stored 0%)
test of mf.gov.pl_1133863028119.zip OK

      

What should I change to have "OK" or "BAD" for all entries instead

addition:

and

(stored X%)

?

+3


source to share


3 answers


You can always use find command:

find . -name "*.zip" -exec zip -T {} \; >> wynik.txt

      



And here you can use options -maxdepth N

to control the depth of your search.

0


source


Replace next line

zip -T $file && echo "OK" >> wynik.txt || echo "BAD" >> wynik.txt



If the result fails &&

and "BAD" is displayed

If the result is successful it &&

will not fail and "OK" will be displayed

0


source


You can also use xargs

and unzip

:

ls -1 | xargs -L1 -I {} unzip -t  {}

      

and if they are subfolders tree

, do:

tree -fai . | xargs -L1 -I {} unzip -t  {}

      

0


source







All Articles