#!/bin/bash
#kenthy#qingdaonews.com 2006-01-03
if [ $# -ne 3 ] ; then
echo "Usage: calculator 14 + 24 "
exit 1
else
case $2 in
+)
echo -e "$1 + $3 = `expr $1 + $3`"
;;
-)
echo -e "$1 - $3 = `expr $1 - $3`"
;;
\*)
echo -e "$1 * $3 = `expr $1 \* $3`"
;;
\/)
echo -e "$1 / $3 = `expr $1 \/ $3`"
;;
*)
echo "Operator Error!!"
echo "Usage: calculator 14 + 24 "
exit 2
;;
esac
fi
阅读(1584) | 评论(0) | 转发(0) |