while

NAME

while - execute commands while a condition is met

SYNOPSIS

C shell

while (expr)
...
end

Korn shell

while list do list done

DESCRIPTION

This command is a built-in command in the C shell and the Korn shell.

C shell

The while(1) command executes the commands between the while and the matching end while expr (an expression, as described in the section on expressions) evaluates non-zero. The elements while and end must appear alone on their input lines. The break(1) and continue(1) commands can be used to terminate or continue the loop prematurely. If the input is a terminal, the user is prompted the first time through the loop (as with foreach(1)).

Korn shell

A while is a prechecked loop. Its body is executed as often as the exit status of the first list is zero. The exit status of a while statement is the last exit status of the list in the body of the loop. If the body is not executed, the exit status is zero.