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 .
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
4 ★ | 1 Vote
You should read it
May be interested
- 11 best tips to get started with Microsoft Loopmicrosoft loop is finally available in public preview this month. loop is microsoft's new age collaboration and database solution with a modern and intuitive drag-and-drop editor, similar to notion.
- The while loop in JavaScriptwhile writing a program, you may encounter a situation where you need to perform an iterative action. in these situations, you will need to write loop commands to reduce the number of lines of code.
- Loop in programming Csimilar to other programming languages, c also provides us with many control structures and allows you to perform complex parts.
- How to Fix Boot Loop Problems in Windowsafter starting your windows device, you may sometimes experience an infinite boot loop issue (also known as an 'infinite boot loop' error).
- While loop in Pythonwhat does the while loop in python do? what is the syntax and how to use while loop? those are the content we will approach in this python lesson.
- What is Loop mail?what is loop mail? to help you with this question, the following article will help you find out what loop mail is.
- For ... loop in JavaScriptthe for ... in loop is used to iterate over the properties of an object. when we haven't discussed the object yet, you may not feel comfortable with this loop. but once you understand how objects work in javascript, you will find this loop very useful.
- Loop control in JavaScriptjavascript provides high control to handle loop commands and switch commands. there may be a situation when you need to exit the loop without having to go to its endpoint. there may also be situations when you want to jump over a part of the code block and start the next loop.
- Why Microsoft Loop Can't Compare to Notionmany people have been using notion for brainstorming for years, so it's interesting to see if loop can replace it as they move deeper into the microsoft ecosystem.
- What is Google Cloud Shell? What's remarkable about Cloud Shell?google cloud shell is an online development and operations environment that you can access anywhere via a web browser. cloud shell is a free service provided by google.