Go forward to Reading Files.
Go backward to This Manual.
Go up to Top.

Getting Started with `awk'
**************************

   The basic function of `awk' is to search files for lines (or other
units of text) that contain certain patterns.  When a line matches one
of the patterns, `awk' performs specified actions on that line.  `awk'
keeps processing input lines in this way until the end of the input
file is reached.

   When you run `awk', you specify an `awk' "program" which tells `awk'
what to do.  The program consists of a series of "rules".  (It may also
contain "function definitions", but that is an advanced feature, so we
will ignore it for now.  See User-defined Functions: User-defined.)
Each rule specifies one pattern to search for, and one action to
perform when that pattern is found.

   Syntactically, a rule consists of a pattern followed by an action.
The action is enclosed in curly braces to separate it from the pattern.
Rules are usually separated by newlines.  Therefore, an `awk' program
looks like this:

     PATTERN { ACTION }
     PATTERN { ACTION }
     ...

Menu

Very Simple
A very simple example.
Two Rules
A less simple one-line example with two rules.
More Complex
A more complex example.
Running gawk
How to run `gawk' programs; includes command line syntax.
Comments
Adding documentation to `gawk' programs.
Statements/Lines
Subdividing or combining statements into lines.
When
When to use `gawk' and when to use other things.