How to compare floating point number in shell scripting ?

Showing Answers 1 - 7 of 7 Answers

Nandu

  • Oct 10th, 2007
 

a1=10.50
b1=10.01
if [ $a1 -gt $b1 ]| bc
then
        echo "greater"
else
        echo "lesser"
fi

  Was this answer useful?  Yes

abdas

  • Jun 23rd, 2011
 

a=10.50
b=11.01

if [ $a -gt $b ]
        then
        echo a is greater than b
else 
        echo a is less than b
fi

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions