Chapter 13. The gawk Scripting Language
gawk is the GNU version of awk, a powerful pattern-matching program for processing text files that may be composed of fixed or variable length records separated by some delineator (by default, a newline character). gawk may be used from the command line or in gawk scripts. Normally you should be able to invoke this utility using either awk or gawk on the shell command line.
This chapter presents the following topics:
Conceptual overview
Command-line syntax
Patterns and procedures
System variables
Operators
Variable and array assignment
Group listing of commands
Alphabetical summary of commands
For more information, see the O’Reilly book sed & awk, 2d ed., by Dale Dougherty and Arnold Robbins.
Conceptual Overview
With gawk, you can:
Conveniently process a text file as though it were made up of records and fields in a textual database.
Use variables to change the database.
Execute shell commands from a script.
Perform arithmetic and string operations.
Use programming constructs such as loops and conditionals.
Define your own functions.
Process the result of shell commands.
Process command-line arguments more gracefully.
Produce formatted reports.
Get Linux in a Nutshell, Third Edition 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.