小编典典

Bash:预期为整数表达

linux

我正在尝试执行简单的数学运算,以检查变量是否大于或等于“ 1.5”,但我正在 [: 2.41: integer expression expected

码:

reSum=$(expr "scale=1;555/230" | bc)

if [ $reSum -ge "1.5" ]; then
...
fi

如何在Shell脚本中进行浮点比较?


阅读 283

收藏
2020-06-02

共1个答案

小编典典

if echo 555 230 | awk ‘{exit $1/$2 >= 1.5 ? 0 : 1}’
then
# …
fi

2020-06-02