Looping statement
A loop is a conditional construct that allows us to perform one or more actions again and again till the conditionistrue as specified in expression. In AWK we can specify a loop using a while
, do
or for
statement.
The while loop
The while
is the simplest looping statement in AWK.A while
statement has a condition and a body.Thebody contains the actionstatementsthat are executedtill the condition is true.Thecondition could be a logical condition or conditional-expressionthatevaluates to true.First while
statement tests the condition; if the condition evaluates to true, then it executes the statements specified in the body. Once all the statements specified in the body have been executed, the condition is again tested and, if it is still true, statements in body executes again.This process is repeated as long as the condition is true.If the conditionreturns false before the first iteration of the loop,the body of the loop never executes and AWK continues with the statements...