Shell until循环
2016-09-12 11:54
274 查看
until 循环执行一系列命令直至条件为 true 时停止。until 循环与 while 循环在处理方式上刚好相反。一般while循环优于until循环,但在某些时候,也只是极少数情况下,until
循环更加有用。
until 循环格式为:
command 一般为条件表达式,如果返回值为 false,则继续执行循环体内的语句,否则跳出循环。
例如,使用 until 命令输出 0 ~ 9 的数字:
#!/bin/bash
a=0
until [ ! $a -lt 10 ]
do
echo $a
a=`expr $a + 1`
done
运行结果:
循环更加有用。
until 循环格式为:
until command do Statement(s) to be executed until command is true done
command 一般为条件表达式,如果返回值为 false,则继续执行循环体内的语句,否则跳出循环。
例如,使用 until 命令输出 0 ~ 9 的数字:
#!/bin/bash
a=0
until [ ! $a -lt 10 ]
do
echo $a
a=`expr $a + 1`
done
运行结果:
0 1 2 3 4 5 6 7 8 9
相关文章推荐
- 【Shell脚本学习20】Shell until循环
- Shell中的循环语句for、while、until实例讲解
- shell的until循环
- 第3章 shell结构化命令------------(while、until循环,九九乘法表)
- 28_Shell语言――while和until循环(while, until, sleep)
- Shell中的循环语句for、while、until实例讲解
- Shell until循环
- Shell编程之while&until循环详解
- shell脚本下的循环语句for、while、until
- Shell 编程8(循环语句until)
- Shell脚本循环语句——until循环
- 十八、Shell until循环
- Shell until循环
- shell循环:for循环、while循环、until循环和select循环
- [9-13]Shell系列4――循环结构for、while、until及跳出循环
- shell浅谈之三for、while、until循环
- 【shell】while与until循环
- shell until循环ping检测ip脚本
- Shell until循环
- Linux Shell系列教程之(十二)Shell until循环