If I understand your question correctly, you want to calculate the difference between dates, in days, for records that match a specified argument. If so, this should be close:
Code:
#! /bin/bash
#
# LQcsegau.sh
# run as: LQcsegau.sh A # (use record type as desired)
# - uses embedded data file name; customize as necessary
#
while read rec; do
#
# Split each record into separate fields
#
rectype=$(echo $rec | cut -d' ' -f1);
d1=$(echo $rec | cut -d' ' -f2);
d2=$(echo $rec | cut -d' ' -f3);
#
# If record type matches that specified on commandline...
#
if [ "$rectype" = "$1" ]; then
#
# normalize dates to seconds-since-epoch
#
date1=$(date -d "$d1" "+%s" );
date2=$(date -d "$d2" "+%s" );
#
# Calculate difference in seconds, convert back to days, and report
#
days=$(( ($date2-$date1)/86400 ));
echo $days;
fi;
#
# Read from data file
#
done < LQcsegau.dat
--- rod.