Several kinds of tasks occur repeatedly
when working with text files.
You might want to extract certain lines and discard the rest.
Or you may need to make changes wherever certain patterns appear,
but leave the rest of the file alone.
Writing single-use programs for these tasks in languages such as C, C++,
or Java is time-consuming and inconvenient.
Such jobs are often easier with
awk utility interprets a special-purpose programming language
that makes it easy to handle simple data-reformatting jobs.
The GNU implementation of
awk is called
gawk; if you
invoke it with the proper options or environment variables
(see Options), it is fully
specification of the
and with the Unix version of
by Brian Kernighan.
This means that all
awk programs should work with
Thus, we usually don’t distinguish between
gawk and other
awk allows you to:
provides facilities that make it easy to:
This Web page teaches you about the
awk language and
how you can use it effectively. You should already be familiar with basic
system commands, such as
ls,2 as well as basic shell
facilities, such as input/output (I/O) redirection and pipes.
Implementations of the
awk language are available for many
different computing environments. This Web page, while describing
awk language in general, also describes the particular
gawk (which stands for
gawk runs on a broad range of Unix systems,
ranging from Intel®-architecture PC-based computers
up through large-scale systems,
such as Crays.
gawk has also been ported to Mac OS X,
Microsoft Windows (all versions) and OS/2 PCs,
(Some other, obsolete systems to which
gawk was once ported
are no longer supported and the code for those systems
has been removed.)
|• History:||The history of |
|• Names:||What name to use to find |
|• This Manual:||Using this Web page. Includes sample input files that you can use.|
|• Conventions:||Typographical Conventions.|
|• Manual History:||Brief history of the GNU project and this Web page.|
|• How To Contribute:||Helping to save the world.|
The 2008 POSIX standard is online at http://www.opengroup.org/onlinepubs/9699919799/.
These commands are available on POSIX-compliant systems, as well as on traditional Unix-based systems. If you are using some other operating system, you still need to be familiar with the ideas of I/O redirection and pipes.