statement

The awk extraction and reporting language is not [[imperative?]]. However, actions within the awk rules may contain *statements* which can be executed sequentially to provide a set of [instruction]s for the computer to follow.

Each line is a separate statement in awk

In awk, a newline character is considered the end of the statement, unless a continuation character has been used at the end of the line. Each line within an awk program is a separate statement or separate rule, and the end of the line is treated as the end of the statement or rule:

The semicolon symbol can be used to separate multiple statements used on a single line

The semicolon symbol can be used to separate statements within a program, allowing multiple statements to be used on a single line. A semicolon after the last statement within a rule is optional and can be omitted:

Statements can be split across several lines by using a continuation character

The awk programming language allows a statement is to be split across several lines, by using a backslash [[continuation_character?]] at the end of the line to be continued:

BEGIN {
  # The backslash symbol can be used to spread a statement across several lines
  print \
    "Hello World!"
  exit
}

Continuation characters can appear anywhere within a statement

In awk, a [[continuation_character?]] can appear anywhere within the statement, including the middle of a string or regular expression:

# Here the regular expression foobar has been split using a continuation character
/foo\
bar/ { print $1 }