If [ `grep ^Z inpfile` ]
then
if [ `awk -F"|" '{print $2} line` -eq "VLD_AB_F" ]
then
echo " Check failed in Z record, line number is .. ,keys are $6"
fi
if [ `awk -F"|" '{print $3} line` -eq "VLD_EF_F" ]
then
echo " Check failed in Z record, line number is .??. ,keys are $5"
fi
###similarly I have to check for all the fields and report the errors##
elif [ `grep ^Y inpfile` ]
then
if [ `awk -F"|" '{print $2} line` -eq "VLD_AB_F" ]
then
echo " Check failed in Y record, line number is ??.. ,keys are $6"
fi
###similarly I have to check for all the fields and report the errors##
I thought of scanning each record and the field in the file by nested if. Wanted to know if we can achieve this thru awk single liners.
I apologize for the confusion. In Field 2,3,4,5 I will check for the following and If I find the match I will echo the message.
ErrCodes: VLD_AB_F|VLD_CD_F|VLD_EF_F|VLD_GH_F
Z|VLD_AB_P|VLD_CD_P|VLD_EF_F|VLD_GH_F|100|UUU|0000-01-01
Y|VLD_AB_F|VLD_CD_F|VLD_EF_P|VLD_GH_P|101|ZZZ|2010-06-23
If field -1 = Z && field2 (delim - 2) = VLD_AB_F Then print"Check failed in Z record, line number is .. ,keys are $6"
If field -1 = Z && field3 (delim - 3) = VLD_CD_F Then print"Check failed in Z record, line number is .. ,keys are $7"
If field -1 = Z && field4 = VLD_EF_F Then print"Check failed in Z record, line number is .. ,keys are $8"
If field -1 = Z && field5 = VLD_GH_F Then print"Check failed in Z record, line number is .. ,keys are $6"
###similarly for Y record
If field -1 = Y && field2 (delim - 2) = VLD_AB_F Then print"Check failed in Y record, line number is .. ,keys are $6"
###---so on for other fields in Y record
###--There will be multiple Z/Y records in the file and I have to scan all the records##