Name
while
Synopsis
while
(expression) commands commandsend
As long as expression
is true (evaluates
to nonzero), evaluate commands
between
while
and end
.
break
and continue
can be used
to terminate or continue the loop.
Example
set user = (alice bob carol ted)
while ($argv[1] != $user[1])
Cycle through each user, checking for a matchshift 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
Get Mac OS X in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.