Bash Control Structures Loop break


Example

Break multiple loop:

arr=(a b c d e f)
for i in "${arr[@]}";do
    echo "$i"
    for j in "${arr[@]}";do
        echo "$j"
        break 2
    done
done

Output:

a
a

Break single loop:

arr=(a b c d e f)
for i in "${arr[@]}";do
    echo "$i"
    for j in "${arr[@]}";do
        echo "$j"
        break
    done
done

Output:

a
a
b
a
c
a
d
a
e
a
f
a