#!/bin/bash

# unzip file.zip
# rm file.zip
printf '' > output-bad-checksums.txt
n=$(cat checklist.txt | wc -l)
cat checklist.txt | {
  i=0 bad=0 bad_bef=0
  while IFS= read -r line; do
    i=$((i+1))
    bad_bef=`echo $bad`
    line_act=`echo $line | sed 's/^.................................//g'`
    echo "$line" | md5sum -c - || bad=$((bad+1))
	if [[ $bad_bef < $bad ]];
	then echo "$line" >> output-bad-checksums.txt
	fi
    clear
    echo -e "$i/$n - checking: \n\n$line_act"
  done
  [ $bad -eq 0 ] || { tput setaf 1;echo "$bad bad checksums check the file output-bad-checksums.txt"; false; } && { tput setaf 2;echo "All good"; }&& rm output-bad-checksums.txt
}
