Until loop in Shell
The while loop is perfect for the situation where you want to execute a set of commands while some conditions are true. Sometimes you need to execute a set of commands until a condition is true, then you need to use a until loop.
The while loop is perfect for the situation where you want to execute a set of commands while some conditions are true. Sometimes you need to execute a set of commands until a condition is true, then you need to use a until loop .
Syntax in Unix / Linux
until command do cac lenh duoc thuc thi toi khi command la true done
Here the command is estimated. If the value is false , the command is executed. If the command is true , then the command will not be executed and the program will jump to the command line after the done command.
For example in Unix / Linux
Here is a simple example that uses a until loop to display numbers from 0 to 9.
#!/bin/sh a = 0 until [ ! $a - lt 10 ] do echo $a a = `expr $a + 1` done
It will produce the following result:
0 1 2 3 4 5 6 7 8 9
According to Tutorialspoint
Previous article: for loop in Shell
Next article: Select loop in Shell
Discover more
Loop in Unix / Linux Insert loops in Unix / Linux Insert while loop in Unix / Linux Syntax in Unix / Linux while loop in Shell for in Shell Loop until loop in ShellShare by
Micah Soto
Update 25 May 2019
You should read it
- Select loop in Shell
- Loop in Unix / Linux
- Control loop in Unix / Linux
- What is a shell?
- Techniques cited in Unix / Linux
- The Quiet Details That Make a Sports Betting Platform Feel Reliable
- Instructions on creating toy set images with ChatGPT AI
- How are AI agents changing the journalism industry?
- Select loop in Shell
- Regular Expression in Unix / Linux
- Basic file system in Unix / Linux