菜鸟请教shell编程问题 case if else
#用一个whileloop直到不想玩while:#
#-p”pleaseinputthefirstnumber(or’q’toquit):”first_numshell编程菜鸟教程。
if[“$first_num”==”q”]
then
echo”bye!”linux shell 菜鸟教程。
exit批处理教程 菜鸟教程。
else
#checkiftheinputisalldigits
re=’^[0-9] $’
if![[$first_num=~$re]]shell脚本在线运行。
then
echo”first_numisnon-numeric,重来!”
continuefi#-p”pleaseinputthesecondnumber(or’q’toquit):”second_num
if[“$second_num”==”q”]
thenshell在线编程网站。

echo”bye!”
exit
else
#checkiftheinputisalldigits
re=’^[0-9] $’常用shell脚本。
if![[$second_num=~$re]]ssh命令。
then
echo”second_numisnon-numeric,重来!”
continuefi#askusertoentertheoperator( ,-,*,/)read-p”pleaseenter运算符号( ,-,*,/):”operatorshell脚本基础教程。
case$operator’ ‘)letresult=$first_num $second_num
echo”$first_num $second_num=”$result你可以自己做这些事情*#这些你可以自己做‘/’#这些你可以自己做*)#anythingelseisinvalid
echo”Invalidoperator,pleaseenter’ *tryagain!”esac
done