Convert string to numeric

Hi,
I have read some figures from a text file by getting the position and wish to do some checking, but it seem like it won't work.

eg. my figure is 0.68 it still go the the else statement,

it seems like it treat it as a text instead of number.

Anybody can Help ? Thanks.

# only one line
cat $outfile | while read line
do
f1=$(echo $line|cut -c 14-17)
f2=$(echo $line|cut -c 19-22)
f3=$(echo $line|cut -c 24-27)
done

echo $f1 $f2 $f3
a=$f1
x=0.5
if [ $a -gt $x ]
then
echo 'Grater ' $f1 $f2 $f3
else
echo 'is ok :'
fi

I'm afraid that you can only do integer arithmetic and comparisons via the shell. One way to get around this is to use a utility like awk or bc to multiply your variables by the same amount, eg....

a=0.89
x=0.5
a=$(echo $a|awk '{print $11000}')
x=$(echo $x|awk '{print $1
1000}')
if [ $a -gt $x ]
then
echo $a Greater than $x
fi

Gives...

890 Greater than 500

Hi,

You can directly use awk

echo $i $j|awk '
{
if ( $1 > $2 )
print $1 " Greater than " $2 "\n"
else
print $1 " Smaller than " $2 "\n"
}'

������
Go on