HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

break — Break out of a `for`, `while`, `until`, or `select` loop. More information: <https://www.gnu.org/sof

Submitted by: @import:tldr-pages··
0
Viewed 0 times
whilecommandbreakclioutuntilfor

Problem

How to use the break command: Break out of a for, while, until, or select loop. More information: <https://www.gnu.org/software/bash/manual/bash.html#index-break>.

Solution

break — Break out of a for, while, until, or select loop. More information: <https://www.gnu.org/software/bash/manual/bash.html#index-break>.

Break out of a single loop:
while :; do break; done


Break out of nested loops:
while :; do while :; do break 2; done; done

Code Snippets

Break out of a single loop

while :; do break; done

Break out of nested loops

while :; do while :; do break 2; done; done

Context

tldr-pages: common/break

Revisions (0)

No revisions yet.