Learning AWK Programming
上QQ阅读APP看书,第一时间看更新

Actions

In pattern-action statements, actions are single or multiple statements that are separated by a newline or semicolon. The statements in actions can include the following:

  • Expression statements:  These are made up of constants, variables, operators, and function calls. For example, x = x+ 2 is an assignment expression.
  • Printing statements: These are print statements made with either print or printf. For example, print "Welcome to awk programming ".
  • Control-flow statements: These consist of various decision-making statements made with if...else and looping statements made with the while, for, and do constructs. Apart from these, break, continue, next, and exit are used for controlling the loop iterations. These are similar to C programming control-flow constructs.
  • { statements }: This format is used for grouping a block of different statements.

We will study these different types of action and pattern statements in detail in future chapters.