1.5. The awk Programming Language
This section presents the following topics:
Conceptual overview
Command-line syntax
Patterns and procedures
Built-in variables
Operators
Variables and array assignment
User-defined functions
Group listing of functions and commands
Implementation limits
Alphabetical summary of functions and commands
1.5.1. Conceptual Overview
awk is a pattern-matching program for processing files, especially when they are databases. The new version of awk, called nawk, provides additional capabilities. (It really isn't so new. The additional features were added in 1984, and it was first shipped with System V Release 3.1 in 1987. Nevertheless, the name was never changed on most systems.) Every modern Unix system comes with a version of new awk, and its use is recommended over old awk.
Different systems vary in what the two versions are called. Some have oawk and awk, for the old and new versions, respectively. Others have awk and nawk. Still others only have awk, which is the new version. This example shows what happens if your awk is the old one:
$ awk 1 /dev/null awk: syntax error near line 1 awk: bailing out near line 1
awk will exit silently if it is the new version.
Source code for the latest version of awk, from Bell Labs, can be downloaded starting at Brian Kernighan's home page: http://cm.bell-labs.com/~bwk. Michael Brennan's mawk is available via anonymous FTP from ftp://ftp.whidbey.net/pub/brennan/mawk1.3.3.tar.gz. Finally, the Free Software Foundation has a version ...
Get sed, awk and Regular Expressions Pocket Reference 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.