I've got bash script for checking 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 of
adding:
and
(stored X%)
?
You always can use find command:
find . -name "*.zip" -exec zip -T {} \; >> wynik.txt
And here you can use -maxdepth N
options to control the depth of finding.
Replace following line
zip -T $file && echo "OK" >> wynik.txt || echo "BAD" >> wynik.txt
If the result is failure &&
will fail and "BAD" will be outputted
If the result is successful &&
will not fail and "OK" will be outputted
You can also use xargs
and unzip
:
ls -1 | xargs -L1 -I {} unzip -t {}
and if they are subfolders tree
would do:
tree -fai . | xargs -L1 -I {} unzip -t {}
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.