我想在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) –