How to compare two "not integer" values in shell script
Posted
by Reem
on Stack Overflow
See other posts from Stack Overflow
or by Reem
Published on 2010-05-04T23:39:43Z
Indexed on
2010/05/04
23:48 UTC
Read the original article
Hit count: 258
I had to do a division in shell script and the best way was:
result1=`echo "scale=3; ($var1 / $total) * 100"| bc -l`
result2=`echo "scale=3; ($var2 / $total) * 100"| bc -l`
but I want to compare the values of $result1
and $result2
Using if test $result1 -lt $result2
or if [ $result1 -gt $result2 ]
didn't work :(
Any idea how to do that?
© Stack Overflow or respective owner