|NO.Z.00026|——————————|LinuxShell|——|Linux&Shell&流程控制.V07|——|until循环|

一、until循环
### --- until循环语法
~~~     再来看看 until 循环,和 while 循环相反,
~~~     until 循环时只要条件判断式不成立则进行循环,并执行循环程序。
~~~     一旦循环条件成立,则终止循环。语法如下:

until [ 条件判断式 ]
    do
        程序
    done
二、until循环实验
### --- 实验一:还是写从 1 加到 100 这个例子,注意和 while 循环的区别:
~~~     例子:从 1 加到 100

[root@localhost ~]# vi sh/until.sh
#!/bin/bash
#从 1 加到 100
# Author: shenchao (E-mail: shenchao@atguigu.com)


i=1
s=0
#给变量 i 和变量 s 赋值
until [ $i -gt 100 ]
#循环直到变量 i 的值大于 100,就停止循环
        do
                s=$(( $s+$i ))
                i=$(( $i+1 ))
        done
echo "The sum is: $s"

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(8)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示