我有:
DIFF=$(( ($END - $START) / 60 ))
echo "Build took $DIFF minutes"
我1:30分钟的输出是:
Build took 1 minutes
我如何在这里使用浮点数,以便我的输出将是:
Build took 1.50 minutes
使用BC获取精度
的例子:
kent$ echo "scale=2;(190-100)/60"|bc
1.50
用变量替换硬编码的数字
我认为bash不支持浮点数。您可以使用bc
命令:
DIFF=$(bc <<< "scale=2; ($END - $START) / 60")
echo "Build took $DIFF minutes"