我需要在shell脚本中进行除法运算,最好的方法是:
result1=`echo "scale=3; ($var1 / $total) * 100"| bc -l`
result2=`echo "scale=3; ($var2 / $total) * 100"| bc -l`
但我想比较$result1
和$result2
的值。
使用if test $result1 -lt $result2
或if [ $result1 -gt $result2 ]
没有起作用:(
有什么办法吗?