The awk programming language was designed to simplify many common text processing tasks. In this chapter, we present a subset that suffices for most of the shell scripts that we use in this book.
For an extended treatment of the awk language, consult any of the books on awk listed in the Chapter 16. If GNU gawk is installed on your system, then its manual should be available in the online info system.
All Unix systems have at least one awk implementation. When the language was
significantly extended in the mid-1980s, some vendors kept the old
implementation as awk, and sometimes
also as oawk, and then named the
new one nawk. IBM AIX and Sun
Solaris both continue that practice, but most others now provide only the
new one. Solaris has a POSIX-compliant version in
/usr/xpg4/bin/awk. In this book, we consider
only the extended language and refer to it as awk, even though you might have to use nawk, gawk,
or mawk on your
We must confess here to a strong bias about awk. We like it. A lot. We have implemented, maintained, ported, written about, and used the language for many years. Even though many awk programs are short, some of our larger awk programs are thousands of lines long. The simplicity and power of awk often make it just the right tool for the job, and we seldom encounter a text processing task in which we need a feature that is not already in the language, or cannot be readily implemented. When we have on occasion rewritten ...