|
地板
楼主 |
发表于 2009-1-2 21:34:00
|
只看该作者
break 与 continue 应用举例
break 举例:#!/bin/bash
#breakout
while : # : 号为永远为真,且 : 和 while 之间要有空格
do
echo -n "Enter any number[1...5]:"
read ANS
case $ANS in
1|2|3|4|5)
echo "You enter a number between 1 and 5."
;;
*)
echo "Wrong number,bye.."
break
;;
esac
done
continue 应用举例:#!/bin/bash
#breakout
while :
do
echo -n "Enter any number[1...5]:"
read ANS
case $ANS in
1|2|3|4|5)
echo "You enter a number between 1 and 5."
;;
*)
echo -n "Wrong number, continue(y/n)?:"
read IS_CONTINUE
case $IS_CONTINUE in
y|Y|yes|Yes)
continue
;;
*)
break
;;
esac
esac
done |
|