
a
awk(1) | awk(1) |
A pattern can consist of two patterns separated by a comma; in this case, the action is performed for all lines from an occurrence of the ®rst pattern though an occurrence of the second.
A relational expression is one of the following:
expression matchop
where a relop is any of the six relational operators in C, and a matchop is either Ä (matches) or !Ä (does not match). A conditional is an arithmetic expression, a relational expression, or a Boolean combination of the two.
The special patterns BEGIN and END can be used to capture control before the ®rst input line is read and after the last. BEGIN and END do not combine with other patterns.
Special Characters
The following special escape sequences are recognized by awk in both regular expressions and strings:
Escape | Meaning |
|
| |
\a | alert character |
| ||
\b | backspace character |
| ||
\f |
| |||
\n |
| |||
\r |
| |||
\t | tab character |
|
| |
\v |
| |||
\nnn | 1- to |
| ||
\xhhh 1- to |
| |||
Variable Names |
|
|
|
|
Variable names with special meanings are: |
| |||
FS |
| Input ®eld separator regular expression; a space character by default; also settable | ||
|
| by option |
| |
NF |
| The number of ®elds in the current record. | ||
NR |
| The ordinal number of the current record from the start of input. Inside a BEGIN | ||
|
| action the value is zero. Inside an | END action the value is the number of the last | |
|
| record processed. |
| |
FNR |
| The ordinal number of the current record in the current ®le. Inside a BEGIN | ||
|
| action the value is zero. Inside an | END action the value is the number of the last | |
|
| record processed in the last ®le processed. | ||
FILENAME | A pathname of the current input ®le. | |||
RS |
| The input record separator; a newline character by default. | ||
OFS |
| The | print statement output ®eld separator; a space character by default. | |
ORS |
| The | print statement output record separator; a newline character by default. | |
OFMT |
| Output format for numbers (default %.6g). If the value of OFMT is not a | ||
|
| |||
CONVFMT |
| Internal conversion format for numbers (default %.6g). If the value of CONVFMT | ||
|
| is not a | ||
SUBSEP |
| The subscript separator string for | ||
|
| "\034" |
| |
ARGC |
| The number of elements in the ARGV array. | ||
ARGV |
| An array of command line arguments, excluding options and the program argu- | ||
|
| ment numbered from zero to | ||
|
| The arguments in ARGV can be modi®ed or added to; ARGC can be altered. As | ||
|
| each input ®le ends, awk will treat the next | ||
|
| current value of | ||
Section 1−36 |
|
| − 3 − | |