builtin
Bash break
Exits n enclosing loops; default n is 1, use positive integer. Returns zero for a valid positive count inside a loop.
Formal Syntax & Structure
bash syntaxbash
break [n]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| n | integer | Number of enclosing loops to exit. |
Return Value
exit status
Exits n enclosing loops; default n is 1, use positive integer. Returns zero for a valid positive count inside a loop.
Working Example
Example Snippetbash
for row in A B; do for col in 1 2; do printf '%s%s\n' "$row" "$col" if [[ $col == 2 ]]; then break 2; fi donedoneprintf '%s\n' end