TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
break statement is a shell builtin command used to prematurely terminate the execution of an enclosing for, while, until, or select loop. When evaluated, it immediately halts the loop’s execution cycle and transfers control flow to the command immediately following the terminated loop structure.
Syntax
Parameters
n(Optional): An integer literal (>= 1) specifying the number of nested loop levels to exit.- If omitted,
ndefaults to1, terminating only the innermost enclosing loop. - If
nis greater than the current depth of nested loops,breakterminates all enclosing loops and transfers control to the statement following the outermost loop.
- If omitted,
Execution Mechanics
- Scope:
breakonly applies to loop constructs. It does not terminate functions, scripts, or subshells (which requirereturnorexit). While frequently nested inside conditional statements (iforcase),breakignores these structures when calculating the depthnand only counts the enclosing loops. - Exit Status: The return status of the
breakcommand is0(success), unless the provided argumentnis not an integer greater than or equal to1. - Control Transfer: Any commands remaining in the current loop iteration after the
breakstatement are bypassed.
Syntax Visualization
Single Loop Termination (break or break 1)
break n)
Master Bash with Deep Grasping Methodology!Learn More





