First page Back Continue Last page Graphics

Loops: do and done

A do-done pair is use to mark the start and end of every type of loop in bash. They frame a block of statements to be executed each time control passes through the loop.

Control over the loop is completely in the hands of whichever one of the control statements for, while, or until that precedes the do-done statement block:

for/while/until loop control

do

statements

done

As with "then" in the if statement, we'll put the "do" after a semicolon in the control line. Similarly, the PDL will ignore the "do" and show the loop end as END FOR, END WHILE, or END UNTIL.