<tt>while <em>condition</em></tt>



next up previous contents
Next: until loop Up: Control Structures Previous: for var in

while condition

The condition involves the test statement seen above, where one value is compared with another. If the comparison is true, the commands within the loop are executed. If not, they are not executed.

Using another form of the above example,

    #!/bin/sh
    while test $# -gt 0; do
        echo parameter $1
        shift
    done
    exit 0

Note that the while and do are on the same line, and that in this case they must be separated by a semicolon. The semicolon is a command separator.



Super-User
Fri Feb 17 15:55:40 EST 1995