11. The awk Programming Language
This chapter presents the following topics:
For more information, see sed & awk , listed in the Bibliography.
11.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.[1 ] 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 exits 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 of awk called gawk , available from ftp://gnudist.gnu.org/gnu/gawk/gawk-3.0.4.tar.gz . All three programs implement "new" awk . Thus, references below such as "nawk only," apply to all three. gawk has additional features.
With original awk , you can:
With nawk , you can also:
In addition, with GNU awk (gawk ), you can: