Code:
> cat chk_valid
#! /bin/bash
#
# script to check on file conditions
ifile="QDB_2008.txt"
line_1=$(head -1 $ifile)
line_lst=$(tail -1 $ifile)
line_cnt=$(cat $ifile | wc -l)
detl_cnt=$((line_cnt-2))
line_1_val=$(echo $line_1 | cut -d"," -f5)
line_lst_val=$(echo $line_lst | cut -d"," -f2 | cut -d"#" -f1)
if [ "$line_1_val" -ne "$line_lst_val" ]
then
echo "Error - header & footer line counts differ"
fi
if [ "$detl_cnt" -ne "$line_1_val" ]
then
echo "Error - # detail lines does not match expected counts"
fi