ITPub博客

首页 > Linux操作系统 > Linux操作系统 > while(liunx,unix)中的循环执行某程序用法

while(liunx,unix)中的循环执行某程序用法

原创 Linux操作系统 作者:yhdmy 时间:2013-04-29 23:35:25 0 删除 编辑
while是用在循环执行某程序
格式1:
while 条件;
do
语句
done

格式2:
while true/:/[1]/[0]
do
语句
done

示范1:
COUNTER=0  
while [  $COUNTER -lt 10 ]; do  
    echo The counter is $COUNTER  
    let COUNTER=COUNTER+1   
done
结果1:
The counter is 0
The counter is 1
The counter is 2
The counter is 3
The counter is 4
The counter is 5
The counter is 6
The counter is 7
The counter is 8
The counter is 9

 示范2:
while true
do
date
sleep 3
done
结果2:
Mon Apr 29 23:51:08 CST 2013
Mon Apr 29 23:51:11 CST 2013
Mon Apr 29 23:51:14 CST 2013
Mon Apr 29 23:51:17 CST 2013
Mon Apr 29 23:51:20 CST 2013
Mon Apr 29 23:51:23 CST 2013

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26148431/viewspace-759537/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 增加votedisk
请登录后发表评论 登录
全部评论
曾就职于铁道科学研究院,太极计算机公司,合力中税。负责过国家电网数据库部署、迁移、升级、灾备等实施规划工作。大唐发电厂、北京市公安局数据库运维及优化工作。现任工场高级DBA岗位,负责oracle、mysql数据库相关工作。拥有Oracle技术10g/11g的 OCP与OCM认证,Oracle YEP成员,OCM联盟成员。

注册时间:2013-04-22

  • 博文量
    111
  • 访问量
    1751093