5.6. Patterns and Actions

5.6.1. Patterns

Awk patterns control what actions awk will take on a line of input. A pattern consists of a regular expression, an expression resulting in a true or false condition, or a combination of these. The default action is to print each line where the expression results in a true condition. When reading a pattern expression, there is an implied if statement. When an if is implied, there can be no curly braces surrounding it. When the if is explicit, it becomes an action statement and the syntax is different. (See "Conditional Statements" on page 207.)

Example 5.23.
% cat employees
						Tom Jones     4424  5/12/66  543354
						Mary Adams    5346  11/4/63  28765
						Sally Chang   1654  7/22/54  650000
						Billy Black   1683  9/23/44  336500 (The ...

Get Linux Shells by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.