Home OS X
OS X Syntax

break

Exit from a foreach, or while loop

SYNTAX
      break

The return status is zero unless n is not greater than or equal to 1.

Example

foreach myloop (1 2 3 4 5)
  echo -n "$myloop"
  if [ "$myloop" -eq 3 ] 
   then 
   break # This line will break out of the loop
  endif
end

break is a builtin command

"Don't worry about the world coming to an end today. It's already tomorrow in Australia." - Charles Schultz

Related commands:

continue - Resume the next iteration of a while or foreach loop.
repeat - Execute a command multiple times
foreach - Loop, expand words, and execute commands
while - Execute commands

Equivalent BASH command:

break
- Exit from a loop.



Back to the Top

Simon Sheppard
SS64.com