9.2. awk script

When specifying awk on the command line, an awk script consists of various actions and patterns.

When awk reads in the records or lines one at a time if looks to see if the -F or the FS option (more on FS later) has been set. If it has it will use this to separate the fields, but if the -F option has not been set then awk will assume that a <space> is the field separator, and it will continue to do this until it hits a new line. When a new line has been reached it then knows it has read in a whole record, and will then start on the next line reading in the next record. This reading process for each record continues until the end-of-file has been reached, or no more text exists.

Using Table 9.1 as a guide, awk reads in the file ...

Get Linux and Unix Shell Programming 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.