Computer - Linux = ZERO..!

Monday, 7 October 2013

In the previous articles on Loop Statements, we have seen how a loop works. The For Loop as well as the While Loop keep executing a block of commands till the condition stays true. Once the condition becomes false, the loop is terminated.

In this article, we will see a different kind of loop that keeps executing a block of commands till the condition becomes true. The loop is known as 'Until' Loop and it works in totally opposite way as that of the 'While' Loop. Before we proceed to the tutorial part, I recommend that you should read my article on While loops and if you are new to Shell Scripting, please read- Getting Started - Linux Shell Scripting Language.

Lets Start!

The 'Until' Loop

The until loop has a similar syntax as that of the while loop, but as quoted earlier, it works in totally opposite manner as that of while loop. Just like while loop, there is a block of commands and there is a condition. The block of commands executes repeatedly till the condition stays False. As soon as the condition becomes true, the 'until' loop terminates. Have a look on 'until' loop syntax: