我想在UNIX中構建一個非常基本的4函數算術腳本,它不喜歡我的算術語句。我試圖用「bash的算術」語法如何在UNIX中執行算術?
從這個來源
http://faculty.salina.k-state.edu/tim/unix_sg/bash/math.html
也當您引用在UNIX變量時,你需要使用「$」符號一個側面說明,你什麼時候不需要?
#!/bin/bash
str1="add"
str2="sub"
str3="div"
str4="mult"
((int3=0))
((int2=0))
((int1=0))
clear
read -p "please enter the first integer" $int1
clear
read -p "Please enter mathmatical operator'" input
clear
read -p "Please enter the second integer" $int2
if [ "$input" = "$str1" ];
then
((int3 = int1+int2))
echo "$int3"
else
echo "sadly, it does not work"
fi;
可能重複[如何在bash腳本中添加數字](http://stackoverflow.com/questions/6348902/how-can-i-add-numbers-in- a-bash-script) –