AWK Information

AWK is a text-processing language commonly used for massaging data. It automatically parses its input into records and automatically parses each record into fields. An AWK program consists of one or more pattern-action pairs. A pattern is matched against the input; if it matches, the action is performed. It has facilities for regular-expression matching and substitution and for other aspects of string processing. Many people now use PERL for similar tasks, but AWK is simpler, cleaner, and easier to learn. Since AWK is effectively a subset of PERL, if you don't know either one you are probably best off starting with AWK and moving on to PERL if you need it. (For more information about PERL, go to the PERL web site.)

There are three main versions that you are likely to encounter on UNIX systems: original ATT AWK, the ATT proprietary revised version NAWK, and the GNU implementation GAWK, which is approximately the same as NAWK. On many systems "awk" and "gawk" refer to the same program, but on some "awk" will be the old ATT version and gawk will be GNU AWK.

The main GAWK web site is: http://www.gnu.org/directory/GNU/gawk.html.

GAWK will be found on all Linux systems and most other UNIX systems. It may be downloaded from any GNU project archive site. GAWK is also available for Windows from http://gnuwin32.sourceforge.net/packages/gawk.htm.

The classic description of AWK, still a good source, is The AWK Programming Language by Alfred V. Aho, Brian W. Kernighan, and Peter J. Weinberger, the creators of AWK. Pointers to the book, downloadable excerpts, and other information may be found on the AWK Book Website.

There is a good on-line AWK tutorial and reference Effective AWK Programmng: A User's Guide for GNU Awk. You can also download this tutorial in several formats, including Postscript, by going to http://www.gnu.org/manual/gawk/index.html.

The fifth section of the UNIX Tutorial Assignment 5: awk provides a good short introduction.

All sorts of information about AWK, including information about different versions and answers to common questions, can be found in the comp.lang.awk FAQ (Frequently Asked Questions).

The reference card for GNU AWK may be downloaded here.