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

if

This is a single and simple if statement used to test a condition/expression. It executes the actions given in the body part only if the conditional expression is evaluated as true. Its syntax is as follows:

if ( conditional-expression )

action

  • if: The keyword
  • conditional-expression: This represents the condition to be tested
  • action: An AWK statement for execution

If two or more actions need to be executed when the condition is true, then those actions should be enclosed in curly braces. The individual AWK action statements should be separated by newlines or semicolons as shown here:

if ( conditional-expression )

action1;

action2;

………  }

If the conditional expression is true, then all the actions enclosed in the braces are executed ...

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