
772
|
Chapter 11: The gawk Programming Language
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
--source='program text'
Use program text as the awk source code. Use this option with -f to mix
command-line programs with awk library files.
--traditional
Disable all gawk-specific extensions, but allow common extensions (e.g., the
** operator for exponentiation).
--version
Print the version of gawk on standard error and exit.
Patterns and Procedures
awk scripts consist of patterns and procedures:
pattern { procedure }
Both pattern and { procedure } are optional. If pattern is missing, { procedure } is
applied to all lines. If { procedure } is missing, the matched line is printed.
Patterns
A pattern can be any of the following:
general expression
/regular expression/
relational expression
pattern-matching expression
BEGIN
END
• General expressions can be composed of quoted strings, numbers, operators,
function calls, user-defined variables, or any of the predefined variables
described later in this chapter in “Built-in Variables.”
• Regular expressions use the extended set of metacharacters, as described in
Chapter 7.
• The ^ and $ metacharacters refer to the beginning and end of a string (such
as the fields), respectively, rather than the beginning and end of a line. In par-
ticular, these metacharacters will not match at a newline embedded in the