首页 > 编程开发 > Shell > 正文  
Linux程式设计-11.Shell Script(bash)--(10)控制圈while/until
出自:http://www.openchess.org/noitatsko/programming/ 2002年02月06日 15:06
while list do list done
当list为True时,该圈会不停地执行。
例一 : 无限回圈写法
#!/bin/sh

while : ; do
echo "do something forever here"
sleep 5
done

例二 : 强迫把pppd杀掉。
#!/bin/sh

while [ -f /var/run/ppp0.pid ] ; do
killall pppd
done



--------------------------------------------------------------------------------

until list do list done
当list为False(non-zero)时,该圈会不停地执行。
例一 : 等待pppd上线。
#!/bin/sh
until [ -f /var/run/ppp0.pid ] ; do
sleep 1
done
】【http://www.trainlinux.com】【Close
『相关资料』
Linux程式设计-11.Shell Script(bash)--(11)参数与变数 (2002-02-06 15:06)
Linux程式设计-11.Shell Script(bash)--(12)函数function (2002-02-06 15:06)
Linux程式设计-11.Shell Script(bash)--(13)Bash内建指令集 (2002-02-06 15:05)
Linux程式设计-11.Shell Script(bash)--(14)Bash内建参数 (2002-02-06 15:05)
Home 

诚恩Linux培训工作室