how to compare string & integer in unix

Hi All,

i am doung sup up of amount column in my file.
tot_val=`awk '{a+=$0}END{printf "%.5f\n",a}' amount`

then i have a checksum in footer.
chk_sum=`tail -1 $FILE_NAME | cut -d~ -f7 | cut -c2-`

but the problem is while executing 1st command i am getting :
27720.75000
& while executing second command i am getting :
00000000000000000027720.75000

if i compare it, i am getting these values are not equal. Can someone help me. what should i change so that it can work.

Well there are lot of options, trimming leading zeroes and doing compare..
below is one of the option..
chk_sum=`tail -1 $FILE_NAME | cut -d~ -f7 | cut -c2-|awk '{print "%.5f",$0}'`

Try this

chk_sum=`tail -1 $FILE_NAME | cut -d~ -f7 | cut -c2- | sed 's/^0*//' `

This will trim leading zeros from chk_sum and then you can compare.

> val1=27720.75000
> val2=00000000000000000027720.75000
> echo $val1
27720.75000
> echo $val2
00000000000000000027720.75000
> echo $val1 - $val2 | bc
0
> if [ `echo $val1 - $val2 | bc` -eq 0 ]; then echo "EQUAL"; fi
EQUAL
>