until 语句也是循环结构,其语法如下:
until [ test ] #理解为满足test条件时不执行until,不满足时才执行
do
commands
done
说明:
until与while的语法基本相同,while时当满足test条件时才执行,不满足条件不执行;而until时不满足test时执行,满足条件时不执行。
演示示例:
[root@Centos8 shell_scripy]# cat until.sh
#!/bin/bash
i=10
until [ KaTeX parse error: Expected 'EOF', got '#' at position 16: i -ge 20 ] #̲满足则不执行,不满足则执行,输…i"
i=expr $i + 1
done
执行结果:
[root@Centos8 shell_scripy]# ./until.sh
10
11
12
13
14
15
16
17
18
19