The while and until statements

The while statement has the general form:

   while command-list1
   do
     command-list2
   done 

The commands in command-list1 are executed; and if the exit status of the last command in that list is 0 (zero), the commands in command-list2 are executed.

The sequence is repeated as long as the exit status of command-list1 is 0 (zero).

The until statement has the general form:

   until command-list1
   do
     command-list2
   done

This is identical in function to the while command except that the loop is executed as long as the exit status of command-list1 is non-zero.

The exit status of a while/until command is the exit status of the last command executed in command-list2. If no such command list is executed, a while/until has an exit status of 0 (zero).


[Home] [Search] [Index] This site maintained by webmaster@softlab.ece.ntua.gr