21.07.2015 Views

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

GAWK: Effective AWK Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

104 <strong>G<strong>AWK</strong></strong>: <strong>Effective</strong> <strong>AWK</strong> <strong>Programming</strong>6.4.3 The do-while StatementThe do loop is a variation of the while looping statement. The do loop executes the bodyonce and then repeats the body as long as the condition is true. It looks like this:dobodywhile (condition)Even if the condition is false at the start, the body is executed at least once (and onlyonce, unless executing body makes condition true). Contrast this with the correspondingwhile statement:while (condition)bodyThis statement does not execute body even once if the condition is false to begin with. Thefollowing is an example of a do statement:{ i = 1do {print $0i++} while (i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!