#个人学习笔记,问题多多
#请大家指正 atyu30#hotmail.com
Korn shell循环
Korn shell有4种类型的循环:for循环, while循环, until循环以及 select循环
1.for循环
# cat /script/for.sh
#!/bin/ksh
#for script
#for variable in wordlist
#do
#commands
#done
for i in a b c d e f
do
print $i
cp 1.sh $i.sh
done
2.while循环
# cat /script/while.sh
#!/bin/ksh
#while script
i=0
while (( i<5 ))
do
print $i
done
3.until循环
# cat /script/until
#!/bin/ksh
#until.sh
#until command
#do
# commands
#done
until ps -ax | grep dhcpd
do
sleep 3
done
4.select循环
# cat /script/select.sh
#!/bin/ksh
#select.sh
#select var in wordlist
#do
# command
#done
#PS3="Please choose one of the three color"
select color in red black blue
do
case $color in
red)
print passion!
break;;
black | blue )
print poise!
break;;
*)
print "$color in not noe of you color" 1>2&
print "Try again."
;;
esac
done
阅读(1105) | 评论(0) | 转发(0) |