這個*有毒
#!/bin/bash
if [ -n $1 -a -n $2 -a -n $3 ]
??????? then
??????? test1=$( echo $1|sed 's/$1//g' )
??????? test2=$( echo $3|sed 's/$1//g' )
??????? if [ -z $test -a -z $test ]
??????????????? then
??????????????? if [ $2 == "+" ]
??????????????????????? then
??????????????????????? result=$(( $1 + $3 ))
??????????????? elif [ $2 == "-" ]
??????????????????????? then
??????????????????????? result=$(( $1 $2 $3))
????????????????#elif [ $2 == "*"? ] 這兒不能用*怎么解決
??????????????? elif [ $2 == "x" ]
??????????????????????? then
??????????????????????? result=$(( $1 * $3 ))
???????????????? elif [ $2 == "/" ]
??????????????????????? then
??????????????????????? result=$(( $1 $2 $3))
??????????????? else
??????????????????????? echo "輸入正確的運算符"
??????????????????????? exit 3
??????????????? fi
??????? else
??????????????? echo "輸入的值要是數(shù)值"
??????????????? exit 2
??????? fi
??????? echo $1 $2 $3 : $result
else
??????? echo "輸入不能為空"
??????? exit 1
fi
2017-11-28
改為單引號括起來,,,你可以去查一下單括號,雙括號,以及中括號的用法