[Next] [Previous] [Up] [Top] [Contents]

9.9 Control Commands

9.9.5 until

This looping feature is only allowed in the Bourne shell.

until condition

do

command list while condition is false

done

The condition is tested at the start of each loop and the loop is terminated when the condition is true. A script equivalent to the while examples above is:

#!/bin/sh

until [ $# -le 0 ]

do

echo $1

shift

done

Notice, though, that here we're testing for less than or equal, rather than greater than or equal, because the until loop is looking for a false condition.

Both the until and while loops are only executed if the condition is satisfied. The condition is evaluated before the commands are executed.


Introduction to Unix - 14 AUG 1996
[Next] [Previous] [Up] [Top] [Contents]