May 2018
Beginner
332 pages
7h 28m
English
awk uses patterns to control the processing of actions. When a pattern or regular expression is found in the record, an action is performed, or if no action is defined then awk simply prints the line on the screen.
This is an example:
$ cat people.txt
The output will be:
Bill Thomas 8000 08/9/1968
Fred Martin 6500 22/7/1982
Julie Moore 4500 25/2/1978
Marie Jones 6000 05/8/1972
Tom Walker 7000 14/1/1977
$ awk '/Bill/' people.txt
The output will be:
Bill Thomas 8000 08/9/1968
In this example, when the Bill pattern is found in the record, that record is printed on screen:
$ awk '$3 > 5000' people.txt
The output will be:
Bill Thomas 8000 08/9/1968
Fred Martin 6500 22/7/1982
Marie Jones 6000 05/8/1972
Tom Walker 7000 14/1/1977 ...