How do you break out of a nested loop in bash?
Tried continue and break. break worked. But want to learn more.
for i in 1 2 3; do
if [[ $flag -eq 1 ]]; then
break
fi
done
How does break actually know the loop is nested?
Instead of break, can I use i=4 or something out of range to exit from a loop.
ifstatement is not a loop, so there is no nested loop in your example.ifstatement, bash has made a note of the fact that it's part of a loop. That's how thebreakstatement knows what to do.