|
problem in string comparision
Hi All,
I've to compare the number of records present in a file against its trailer count.
for ex:
rec_cnt=$(awk 'END{print NR}' file.txt)
trl_cnt=$(tail -1 file.txt| cut -c1-6)
problem is trailer is appended with zero's and while comparing it is giving problem.
i.e, rec_cnt=9 and trl_cnt=000009
eventhough both are 9 while comparing Iam facing problem
if [ "$rec_cnt" -ne "$trl_cnt" ]; then
echo "Error: Invalid trailer count"
fi
How to equal both the values? pls suggest me.
With Regards / Ganapati
|