October 2001
Intermediate to advanced
1040 pages
22h 50m
English
A regular expression to awk is a pattern that consists of characters enclosed in forward slashes. Awk supports the use of regular expression metacharacters (same as egrep) to modify the regular expression in some way. If a string in the input line is matched by the regular expression, the resulting condition is true, and any actions associated with the expression are executed. If no action is specified and an input line is matched by the regular expression, the record is printed. See Table 5.5.
% nawk '/Mary/' employees Mary Adams 5346 11/4/63 28765 |
EXPLANATIONAll lines in the employees file containing the regular expression pattern Mary are displayed. |
% nawk '/Mary/{print $1, $2}' ... |
Read now
Unlock full access