Gawk/This-Manual
Next: Conventions, Previous: Names, Up: Preface [Contents][Index]
Using This Book
The term awk
refers to a particular program as well as to the language you
use to tell this program what to do. When we need to be careful, we call
the language “the awk
language,”
and the program “the awk
utility.”
This Web page explains
both how to write programs in the awk
language and how to
run the awk
utility.
The term “awk
program” refers to a program written by you in
the awk
programming language.
Primarily, this Web page explains the features of awk
as defined in the POSIX standard. It does so in the context of the
gawk
implementation. While doing so, it also
attempts to describe important differences between gawk
and other awk
implementations.5
Finally, it notes any gawk
features that are not in
the POSIX standard for awk
.
This Web page has the difficult task of being both a tutorial and a reference. If you are a novice, feel free to skip over details that seem too complex. You should also ignore the many cross-references; they are for the expert user and for the Info and HTML versions of the Web page.
There are sidebars scattered throughout the Web page. They add a more complete explanation of points that are relevant, but not likely to be of interest on first reading. All appear in the index, under the heading “sidebar.”
Most of the time, the examples use complete awk
programs.
Some of the more advanced sections show only the part of the awk
program that illustrates the concept being described.
Although this Web page is aimed principally at people who have not been
exposed
to awk
, there is a lot of information here that even the awk
expert should find useful. In particular, the description of POSIX
awk
and the example programs in
A Library of awk
Functions, and
in
Practical awk
Programs,
should be of interest.
This Web page is split into several parts, as follows:
- Part I describes the
awk
language and thegawk
program in detail. It starts with the basics, and continues through all of the features ofawk
. It contains the following chapters:- - Getting Started with
awk
, provides the essentials you need to know to begin usingawk
. - - Running
awk
andgawk
, describes how to rungawk
, the meaning of its command-line options, and how it findsawk
program source files. - - Regular Expressions,
introduces regular expressions in general, and in particular the flavors
supported by POSIX
awk
andgawk
. - - Reading Input Files,
describes how
awk
reads your data. It introduces the concepts of records and fields, as well as thegetline
command. I/O redirection is first described here. Network I/O is also briefly introduced here. - - Printing Output,
describes how
awk
programs can produce output withprint
andprintf
. - - Expressions, describes expressions, which are the basic building blocks for getting most things done in a program.
- - Patterns, Actions, and Variables,
describes how to write patterns for matching records, actions for
doing something when a record is matched, and the predefined variables
awk
andgawk
use. - - Arrays in
awk
, coversawk
’s one-and-only data structure: the associative array. Deleting array elements and whole arrays is described, as well as sorting arrays ingawk
. The chapter also describes howgawk
provides arrays of arrays. - - Functions,
describes the built-in functions
awk
andgawk
provide, as well as how to define your own functions. It also discusses howgawk
lets you call functions indirectly.
- - Getting Started with
Part II shows how to use
awk
andgawk
for problem solving. There is lots of code here for you to read and learn from. This part contains the following chapters:- - A Library of
awk
Functions, provides a number of functions meant to be used from mainawk
programs. - - Practical
awk
Programs, provides many sampleawk
programs.
Reading these two chapters allows you to see
awk
solving real problems.- - A Library of
- Part III focuses on features specific to
gawk
. It contains the following chapters:- - Advanced Features of
gawk
, describes a number of advanced features. Of particular note are the abilities to control the order of array traversal, have two-way communications with another process, perform TCP/IP networking, and profile yourawk
programs. - - Internationalization with
gawk
, describes special features for translating program messages into different languages at runtime. - - Debugging
awk
Programs, describes thegawk
debugger. - - Namespaces in
gawk
, describes howgawk
allows variables and/or functions of the same name to be in different namespaces. - - Arithmetic and Arbitrary-Precision Arithmetic with
gawk
, describes advanced arithmetic facilities. - - Writing Extensions for
gawk
, describes how to add new variables and functions togawk
by writing extensions in C or C++.
- - Advanced Features of
- Part IV provides the appendices, the Glossary, and two licenses that cover
the
gawk
source code and this Web page, respectively. It contains the following appendices:- - The Evolution of the
awk
Language, describes how theawk
language has evolved since its first release to the present. It also describes howgawk
has acquired features over time. - - Installing
gawk
, describes how to getgawk
, how to compile it on POSIX-compatible systems, and how to compile and use it on different non-POSIX systems. It also describes how to report bugs ingawk
and where to get other freely availableawk
implementations. - - Implementation Notes,
describes how to disable
gawk
’s extensions, as well as how to contribute new code togawk
, and some possible future directions forgawk
development. - - Basic Programming Concepts, provides some very cursory background material for those who are completely unfamiliar with computer programming.
- - The Glossary, defines most, if not all, of the significant terms used throughout the Web page. If you find terms that you aren’t familiar with, try looking them up here.
- - GNU General Public License, and
GNU Free Documentation License,
present the licenses that cover the
gawk
source code and this Web page, respectively.
- - The Evolution of the
Footnotes
(5)
All such differences
appear in the index under the
entry “differences in awk
and gawk
.”
Next: Conventions, Previous: Names, Up: Preface [Contents][Index]