0
的浮点精确度,我有:使用bash
DIFF=$((($END - $START)/60))
echo "Build took $DIFF minutes"
我为1:30分钟输出:
Build took 1 minutes
如何使用此浮点使我的输出将是:
Build took 1.50 minutes
的浮点精确度,我有:使用bash
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"
'$(BC <<< “规模= 2;($ END - $ START)/ 60”)'你的意思 – BeniBela
@BeniBela:+1,更新我的帖子。 –