【发布时间】:2011-02-15 17:08:50
【问题描述】:
我必须在 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 ] 不起作用:(
知道怎么做吗?
【问题讨论】:
标签: linux comparison shell conditional-statements bc