[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
4. Reading Input Files
In the typical awk
program,
awk
reads all input either from the
standard input (by default, this is the keyboard, but often it is 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, processing 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 section Built-in Variables).
The input is read in units called records, and is processed by the rules of your program one record at a time. By default, each record is one line. Each record is automatically split into chunks called fields. This makes it more convenient for programs to work on the parts of a record.
On rare occasions, you may need to use the getline
command.
The getline
command is valuable, both because it
can do explicit input from any number of files, and because the files
used with it do not have to be named on the awk
command line
(see section Explicit Input with getline
).
4.1 How Input Is Split into Records | Controlling how data is split into records. | |
4.2 Examining Fields | An introduction to fields. | |
4.3 Nonconstant Field Numbers | ||
4.4 Changing the Contents of a Field | ||
4.5 Specifying How Fields Are Separated | The field separator and how to change it. | |
4.6 Reading Fixed-Width Data | Reading constant width data. | |
4.7 Defining Fields By Content | ||
4.8 Multiple-Line Records | Reading multi-line records. | |
4.9 Explicit Input with getline | Reading files under explicit program control
using the getline function.
| |
4.10 Directories On The Command Line | What happens if you put a directory on the command line. |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |