谁来帮我解答一下这段代码有什么问题

#!/bin/bash

read -t 30 -p "please input two number:" number

read -t 30 -p "please input yunsuanfu:" number2

read -t 30 -p "please input number" number3

if [ -n "$number" -a -n "$number2" -a -n "$number3" ]

then

test1=$(echo number | sed 's/[0-9]//g')

test2=$(echo number3 | sed 's/[0-9]//g')

test3=$(echo number2 | sed 's/[+-*/]//g')

if [-z "$test1" -a -z "$test -a -z "$test" ]

then

case "$number2" in

"+")

        echo $(( "$number1" + "$number2" ))

        ;;

"*")

        echo $(( "$number1 * "$number2))

        ;;

"-")

        echo $(( "$number1" - "$number2" ))

        ;;

esac


fi

fi


kkkbbb
浏览 1436回答 2
2回答

若相望

#!/bin/bashread -t 30 -p "please input  number:" number1read -t 30 -p "please input number:" number2read -t 30 -p "please input fuhao" number3if [ -n "$number1" -a -n "$number2" -a -n "$number3" ]thentest1=$(echo $number1 | sed 's/[0-9]//g')test2=$(echo $number2 | sed 's/[0-9]//g')test3=$(echo "$number3" | sed 's/[\+\-\*\/]//g')if [ -z "$test1" -a -z "$test2" -a -z "$test3" ]thencase "$number3" in'+')        echo $(( $number1 + $number2 ))        ;;'*')        echo $(( $number1 * $number2 ))        ;;'-')        echo $(( $number1 - $number2 ))        ;;'/')        echo $(( $number1 / $number2 ))        ;;esacfifi刚才那个有bug,看这个

若相望

#!/bin/bash read -t 30 -p "please input  number:" number1 read -t 30 -p "please input number:" number2 read -t 30 -p "please input fuhao" number3 if [ -n "$number1" -a -n "$number2" -a -n "$number3" ] then test1=$(echo $number1 | sed 's/[0-9]//g') test2=$(echo $number2 | sed 's/[0-9]//g') test3=$(echo $number3 | sed 's/[\+\-\*\/]//g') if [ -z "$test1" -a -z "$test2" -a -z "$test3" ] then case "$number3" in '+')         echo $(( $number1 + $number2 ))         ;; '*')         echo $(( $number1 * $number2 ))         ;; '-')         echo $(( $number1 - $number2 ))         ;; '/')         echo $(( $number1 / $number2 ))         ;; esac fi fi
打开App,查看更多内容
随时随地看视频慕课网APP