#!/bin/bash
if [ $# -ne 3 ]
then
echo "Usage: $0 num1 + num2"
fi
case $2 in
+)
echo $1$2$3=`expr $1 + $3`
;;
-)
echo $1$2$3=`expr $1 - $3`
;;
*)
echo $1$2$3=`expr $1 \* $3`
;;
/)
echo $1$2$3=`expr $1 / $3`
;;
*)
echo must in \'+-*/\'
;;
esac
#####################################
#!/bin/bash
operator="+ - \* / exit"
echo -n "please input two number:"
read no1 no2
echo number is : $no1 $no2
select i in $operator
do
case $i in
+)
result=$(($no1+$no2))
echo "$result"
;;
-)
result=$(($no1-$no2))
echo "$result"
;;
*)
result=$(($no1 \* $no2))
echo ${result}
;;
/)
result=$(($no1 / $no2))
echo "$result"
;;
exit)
echo "exit.."
exit
;;
esac
done
阅读(624) | 评论(1) | 转发(0) |