I have a small grepping problem in my script.I am having a file from which i need to make sure "#^A17" is the last updation (Next # can be ignored) before ################.The idea behind this is, if this file contains "A17" as the last updation, i need to do a particular activity. please help me out in this as this is an urgent requirement. I want to make a loop in such a way that if "A17" is the last updation, i need to do a task.
Yes. But that was not the end of the file, it is just the end of the commending part. For clarification, i will paste more part of the file.
#^ A14 02/11/2010 Changed ksh back to sh D.Chesmore
#^ A15 02/17/2010 Changed linux rh5 grep to include only su D.Chesmore
#^ A16 02/17/2010 adjust REPORT.reduced logic Heermance
# fixed one of Dan's lines
#^ A17 03/04/10 Fully qualify st00ctrl Hartsock
#
###############################################################################
NUM=$(awk '/^#\^ A[0-9]+/ {C=$2} END {print C}' file)
if [ "$NUM" = "A17" ]; then
echo "last comment is A17"
else
echo "last comment is something else"
fi
chk='A17'
awk '
/#\^ / {upd=$2}
END {if ($upd) exit (tolower(upd)==tolower(check) ? 10 : 11)}
' check=$chk inputfile
sts=$?
case $sts in
10) echo "'$chk' is the last update." ;;
11) echo "'$chk' isn't the last update." ;;
9) echo "Update id not found!." ;;
*) echo "Error!" ;;
esac