until loop

The until loop executes the commands between the do and done statements as long as the tested condition is false. Here is the syntax:

until [conditional-expression]
do
commands
done

Here is a simple example:

NUM=0
until [ $NUM == 5 ]
do
echo “The number is $NUM.”
let NUM=$NUM+1
done

In the example above you can see that the until loop executes until the value of the NUM variable becomes 5:

linux until loop

Subscribe to our Newsletter

Like us on Facebook

top
Geek University 2019