Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有:
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命令:
bc
DIFF=$(bc <<< "scale=2; ($END - $START) / 60") echo "Build took $DIFF minutes"