Go forward to Printing.
Go backward to Getting Started.
Go up to Top.
Reading Input Files
In the typical `awk' program, all input is read either from the
standard input (by default the keyboard, but often a pipe from another
command) or from files whose names you specify on the `awk' command
line. If you specify input files, `awk' reads them in order, reading
all the data from one before going on to the next. The name of the
current input file can be found in the built-in variable `FILENAME'
(see Built-in Variables.).
The input is read in units called records, and processed by the
rules one record at a time. By default, each record is one line. Each
record is split automatically into fields, to make it more convenient
for a rule to work on its parts.
On rare occasions you will need to use the `getline' command, which
can do explicit input from any number of files (*note Explicit Input
with `getline': Getline.).
- Controlling how data is split into records.
- An introduction to fields.
- Non-Constant Fields
- Non-constant Field Numbers.
- Changing Fields
- Changing the Contents of a Field.
- Field Separators
- The field separator and how to change it.
- Constant Size
- Reading constant width data.
- Multiple Line
- Reading multi-line records.
- Reading files under explicit program control
using the `getline' function.
- Close Input
- Closing an input file (so you can read from
the beginning once more).