Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-13-2003
kflee2000 kflee2000 is offline
Registered User
 

Join Date: Nov 2003
Posts: 1
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
Sponsored Links