我想要使用 bash 脚本的快速示例:
#!/bin/bash
echo "Insert the price you want to calculate:"
read float
echo "This is the price without taxes:"
echo "scale=2; $float/1.18" |bc -l
read -p "Press any key to continue..."
bash scriptname.sh
Run Code Online (Sandbox Code Playgroud)
假设价格是:48.86 答案将是:41.406779661(实际上是 41.40 因为我正在使用scale=2;)
我的问题是: 我如何舍入第二个小数以这种方式显示答案?:41.41