#!/bin/bash
if [ "$2" == "" ]; then
echo "usage: ./check_sum.sh dir_name checksum_file"
exit
fi
file_name=($(cat $1/$2 | tail -n +3 | sort -k 3 | awk '{print $3}'))
ref=($(cat $1/$2 | tail -n +3 | sort -k 3 | awk '{print $1}'))
#imp=($(cksum $1/* | grep -v $2 | sort -k 3 | awk '{print $1}'))
pass_flag="passed"
for ((i=0;i<=${#ref[@]};i++)); do
if [ "$file_name[i]" != "" ]; then
if [ -f "$1/${file_name[i]}" ]; then
imp=($(cksum "$1/${file_name[i]}" | grep -v $2 | sort -k 3 | awk '{print $1}'))
if [ "${ref[i]}" == "${imp}" ]; then
echo "${file_name[i]}: ${ref[i]} == ${imp}"
else
echo "${file_name[i]}: ${ref[i]} != ${imp}"
pass_flag="failed"
fi
fi
fi
done
echo "INFO: file check is ${pass_flag}"
echo $(date)