这个*有毒
#!/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 "输入的值要是数值"
exit 2
fi
echo $1 $2 $3 : $result
else
echo "输入不能为空"
exit 1
fi