您的位置:首页 > 运维架构 > Shell

linux shell编程(计算器示例)

2015-12-06 21:14 465 查看
#!/bin/bash
while [ "0" == "0" ]
do
read -p "please in put the number1 :" num1
read -p "please in put the number2 : " num2
read -p "please in put your wants : " flag
if [ "$num1" == "0" ] && [ "$num2" == "0" ];then
break
fi
case $flag in
"+")
echo $(($num1+$num2))
;;
"-")
echo $(($num1-$num2))
;;
"*")

echo $(($num1*$num2))
;;
"/")
echo $(($num1/$num2))
;;
"%")
echo $(($num1%$num2))
;;
esac
read -p "do you want to continue : " yn
if [ "$yn" == "N" ] || [ "$yn" == "n" ];then
break
fi
done
exit 0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: