#! /bin/sh
# 加减乘除的小脚本,主要练习case语句
case $2 in
+)
echo "$1 + $3 = `expr $1 + $3` "
;;
-)
echo "$1 - $3 = `expr $1 - $3`"
;;
\*)
echo "$1 * $3 = `expr $1 \* $3`"
;;
/)
if [ $3 = 0 ]
then
echo "除数不能为0"
else
echo "$1 / $3 = `expr $1 / $3`"
fi
;;
*)
echo "您的输入不符合规范,请重新输入"
esac
时间: 2024-10-12 15:58:19