start page | rating of books | rating of authors | reviews | copyrights

UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: wait Chapter 5
The C Shell
Next: Reference: @
 

while



while (



expression



)

      

commands

 

end

As long as expression is true (evaluates to non-zero), evaluate commands between while and end . break and continue can be used to terminate or continue the loop. See also example under shift .

Example

set user = (alice bob carol ted) while ($argv[1] != $user[1])    #Cycle through each user, checking for a match    shift user    #If we cycled through with no match...    if ($#user == 0) then      echo "$argv[1] is not on the list of users"      exit 1    endif end


Previous: Reference: wait UNIX in a Nutshell: System V Edition Next: Reference: @
Reference: wait Book Index Reference: @

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System