Loops

Sometimes you might want an operation to repeat until a certain condition becomes true (or until a certain condition is no longer true). This is where looping statements come into play. The Bourne shell supports three different looping constructs for these situations. These are the while loop, the until loop, and the for loop. We will look at each one separately.

The while Loop

The while loop repeats the statements inside the loop as long as the condition that is being tested is true. Depending on your point of view, it could also be said that the while loop repeats the statements inside the loop until the condition that is being tested becomes false. If the condition is already false the first time it is evaluated, the loop will never ...

Get FreeBSD® Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.