Im facing an issues while trying to compare string using IF stmt, my code is:
chkMsgName=`Service Fee Detail`
if [ $ctrlSrvcFeeMsgNm == $chkMsgName ]
then
if [ $ctrlSrvcFeeCnt == $cntWrdSrvcFee ]
then
if [ $ctrlSrvcFeeLnItmCnt == $cntWrdSrvcFeeLnItm ]
then
echo "Valid File Ready for processing"
fi
fi
fi
im getting the following error...
parsingIfNew.ksh[65]: [: Fee: unknown operator
Please help me in sorting out this error.... Thanks in advance...
Please try the following (copy it => same sequence) :
chkMsgName="Service Fee Detail"
if [ $ctrlSrvcFeeMsgNm == $chkMsgName ]
then
if [ $ctrlSrvcFeeCnt == $cntWrdSrvcFee ]
then
if [ $ctrlSrvcFeeLnItmCnt == $cntWrdSrvcFeeLnItm ]
then
echo "Valid File Ready for processing"
fi
fi
fi
chkMsgName="Service Fee Detail"
if [ "$ctrlSrvcFeeMsgNm" = "$chkMsgName" ]
then
if [ "$ctrlSrvcFeeCnt" = "$cntWrdSrvcFee" ]
then
if [ "$ctrlSrvcFeeLnItmCnt" = "$cntWrdSrvcFeeLnItm" ]
then
echo "Valid File Ready for processing"
fi
fi
fi
Or, more concisely:
chkMsgName="Service Fee Detail"
if [ "$ctrlSrvcFeeMsgNm" = "$chkMsgName" ] &&
[ "$ctrlSrvcFeeCnt" = "$cntWrdSrvcFee" ] &&
[ "$ctrlSrvcFeeLnItmCnt" = "$cntWrdSrvcFeeLnItm" ]
then
echo "Valid File Ready for processing"
fi