0
我想輸出結果在bash中使用bc浮點運算。但我得到以下代碼的輸出。如何從這裏得到乘法結果,以及爲什麼我得到的命令不是找到。在bash腳本中使用bc
#!/bin/bash
v1=3.41
v2=45
v3= $(bc <<< "scale=4;$v1 + $v2")
echo $v3
v3= $(bc <<< "scale=4;$v1 - $v2")
echo $v3
v3= $(bc <<< "scale=4;$v1/$v2")
echo $v3
v3= $(bc <<< "scale=4;$v1 % $v2")
echo $v3
v3 = $(bc <<< "scale=4;$v1 * $v2")
echo $v3
輸出我得到低於:
[email protected] ~ $ bash bc.sh
bc.sh: line 4: 48.41: command not found
bc.sh: line 6: -41.59: command not found
bc.sh: line 8: .0757: command not found
bc.sh: line 10: .0035: command not found
bc.sh: line 12: v3: command not found
這將是很好,如果你可以看看:[我應該怎麼做當有人回答我的問題?](http://stackoverflow.com/help/someone-answers) – Cyrus
請看看:http: //www.shellcheck.net/ – Cyrus