break and continue
Builtins that change a loop's flow: break leaves the loop at once and continue skips to the next turn.
In more detail
Both take an optional number to act on an enclosing loop, as in break 2. Use them sparingly; a clearer loop test is often better.
Related terms
- for loop — A loop that runs its body once for each item in a list or other collection, setting a loop variable to the current item.
- while loop — A loop that keeps repeating its block as long as a condition stays true, checking the condition before each pass.
Taught in
- Loops: for, while, until, break, continue — Bash Scripting & Command Line Automation