do...while loop statement

In the AWK while loop, the condition is checked at entry, so it is called an entry-controlled loop. The do...while loop is an exit-controlled loop; the condition is checked at exit time. The do...while loop always executes the body at least once and then repeats the body as long as the condition is true.

It differs from the while and for in a way; it tests the conditional-expressions at the bottom instead of the top, so it will always execute the body once, even if the condition evaluates to false as illustrated in Figure 7.6. Its syntax is as follows:


action statements

while ( conditional-expression )


Following figure 7.6 illustrates the working of a do-while loop statement in AWK programming:

Figure 7.6: ...

Get Learning AWK Programming now with O’Reilly online learning.

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