Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3285592
  • 博文数量: 815
  • 博客积分: 12898
  • 博客等级: 上将
  • 技术积分: 7883
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-25 09:57
文章分类

全部博文(815)

文章存档

2014年(1)

2011年(46)

2010年(192)

2009年(121)

2008年(70)

2007年(385)

分类:

2007-05-27 13:40:50

#个人学习笔记,问题多多
#请大家指正 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
   

阅读(1061) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~