Revision 2 not available (showing current revision instead)

continuation

Line continuation enables long lines of code to split across several lines for the purpose of making them easier to read.

The backslash symbol as a continuation character

In awk, the backslash symbol can be used as a continuation character, enabling a statement to be split across several lines:

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

Continuation characters must be appropriately placed within a statement

In awk, a continuation character should not be placed in the middle of a keyword, [[literal_string?]] or regular expression:

 # Do not split a regular expression
 # /foo\
 # bar/ { print $1 }
 
 # Whitespace is the best place to split a line
 /foobar / \
 { print $1 }
 
 # Comments cannot be split with a backslash symbol \
 # because the backlash is treated as part of the comment