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. Current versions of Gawk support Unicode. 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:

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 Microsoft Windows from

The Heirloom Toolchest contains a version of NAWK that provides full Unicode support. While not identical to GAWK, it is very similar. (Note: to get Unicode to work properly using this version of nawk, it is necessary to set the locale to UTF-8. In the csh, do: setenv LC_CTYPE UTF-8. In bash, LC_CTYPE=UTF-8; export LC_CTYPE;)

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.

The principal documentation for GAWK is the Reference Manual.

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.