"Awk - a pattern scanning and processing language" - читать интересную книгу автора (Aho A.V.)




Awk -- A Pattern Scanning and
Processing Language
(Second Edition)


Alfred V. Aho

Brian W. Kernighan

Peter J. Weinberger

Bell Laboratories
Murray Hill, New Jersey 07974



ABSTRACT

Awk is a programming language whose basic
operation is to search a set of files for pat-
terns, and to perform specified actions upon lines
or fields of lines which contain instances of
those patterns. Awk makes certain data selection
and transformation operations easy to express; for
example, the awk program

length > 72

prints all input lines whose length exceeds 72
characters; the program

NF % 2 == 0

prints all lines with an even number of fields;
and the program

{ $1 = log($1); print }

replaces the first field of each line by its loga-
rithm.

Awk patterns may include arbitrary boolean
combinations of regular expressions and of rela-
tional operators on strings, numbers, fields,
variables, and array elements. Actions may
include the same pattern-matching constructions as
in patterns, as well as arithmetic and string