Skip to content

Using ‘break’ and ‘continue’ to exit loops in bash

The commands for looping in bash are extremely useful. They allow you to run a series of commands as many times as needed to process a large collection of data. The break and continue commands provide another special option. They allow you to exit a loop early or skip the remaining commands in the loop and return to the beginning.

Both the break and the continue commands are meant to be used only in for, while and until loops. In fact, if you try to invoke the break command on its own, bash will tell you just that.

To read this article in full, please click here

Source:: Network World – Data Center