为了账号安全,请及时绑定邮箱和手机立即绑定

大神,这是哪里错了

大神,这是哪里错了

阿强0519 2019-05-25 12:12:55
 1 #!/bin/bash  2   3 ##计算器脚本  4   5 read -p "Please input a number:" num1  6 read -p "Please input a yunsuanfu:" ope  7 read -p "PLease input another number:" num2  8 ##先输入运算符和要运算的数字  9  10 if [ !-z "$num1" -a !-z "$num2" -a -z "$ope" ] 11         then 12         ##判断是否有输入数字和运算符 13         test1=$(echo $num1 | sed 's/[0-9]//g') 14         test2=$(echo $num2 | sed 's/[0-9]//g') 15         ##判断输入的num1和num2是否为数字,运算符是否正确 16                 if [-z "$test1" -a -z "$test2" -a -z "$ope" ] 17                         then 18                                 if ["$ope"=="+"];then 19                                         sum=$(( $num1 + $num2 )) 20                                 elif ["$ope"=="-"];then 21                                         sum=$(( $num1 - $num2 )) 22                                 elif ["$ope"=="*"];then 23                                         sum=$(( $num1 * $num2 )) 24                                 elif ["$ope"=="/"];then 25                                         sum=$(( $num1 / $num2 )) 26                                 else 27                                         echo "please input a true ope" 28                                 exit 10 29                                 #判断是否是正确的运算符 30                                 fi 31                 else 32                         echo "Please input a true num" 33                         exit 11 34                 fi 35         else 36                 echo "qing shu ru nei rong" 37                 exit 12 38 fi 39  40 echo "$num1 $ope $num2 = $sum"test.sh: line 10: [: too many argumentsqing shu ru nei rong
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 967 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信