求大神指教,哪里有问题!
1 #!/bin/bash
2 read -p "请输入一个数字:" num1
3 read -p "请输入运算符:" ope
4 read -p "请输入第二个数:" num2
5 if [ -n "$num1" -a -n $num2" -n "$ope" ]
6 then
1 #!/bin/bash
2 read -p "请输入一个数字:" num1
3 read -p "请输入运算符:" ope
4 read -p "请输入第二个数:" num2
5 if [ -n "$num1" -a -n $num2" -n "$ope" ]
6 then
7 test1=$(echo $num1 | sed 's/[0-9]//g')
8 test2=$(echo $num2 | sed 's/[0-9]//g')
9 if [ -z "$test1" -a -z "$test2" ]
10 then
11 if [ "$ope" == "+" ]
12 then
13 sum=$(($num1+$num2))
14 elif [ "$ope" == "-" ]
15 then
16 sum=$(($num1-$num2))
17 elif [ "$ope" == "*" ]
18 then
19 sum=$(($num1*$num2))
20 elif [ "$ope" == "/" ]
21 then
22 sum=$(($num/$num2))
23 else
24 echo "请输入正确运算符"
25 exit 1
26 fi
27 else
28 echo "请输入数字类型"
29 exit 2
30 fi
31 else
32 echo "输入不能不为空"
33 exit 3
34 fi
35 echo "$num1 $ope $num2 :$sum"
报错信息:
./sum.sh:行35: 寻找匹配的 `"' 是遇到了未预期的文件结束符
./sum.sh:行37: 语法错误: 未预期的文件结尾