> For the complete documentation index, see [llms.txt](https://beret81.gitbook.io/study-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://beret81.gitbook.io/study-notes/shell-jiao-ben/shell-liu-cheng-kong-zhi-until-xun-huan-yu-ju.md).

# shell流程控制-until循环语句

### 一、until介绍

和while正好相反，until是条件为假开始执行，条件为真停止执行。

### 二、until语法

```
until [ condition ]      #注意，条件为假until才会循环，条件为真，until停止循环 
do
         commands代码块
done

```

### 三、案例

```
#打印10-20数字
#!/bin/bash
init_num=10
until [ $init_num -gt 20 ]
   do
       echo $init_num
       init_num=$((init_num + 1))
done
#输出
[root@www ~]# sh until1.sh 
10
11
12
13
14
15
16
17
18
19
20
```
