O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The for loop statement

The AWK for statement functionally works the same as the AWK while loop; however, the for statement syntax is much easier to use. Its syntax is as follows:

for ( initialization; conditional-expression; increment / decrement )

action statements

The description of different keywords and statement used in for loop syntax above is as follows:

  • initialization: Sets the initial value for the counter variable
  • conditional-expression: States a condition that is tested at the top of the loop
  • increment/decrement: Increment/decrement the counter each time at the bottom of the loop, just before testing the conditional-expression again

For statement starts by performing initialization action, then it checks the conditional-expression ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required