[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
getline
So far we have been getting our input data from awk
's main
input stream--either the standard input (usually your terminal, sometimes
the output from another program) or from the
files specified on the command line. The awk
language has a
special built-in command called getline
that
can be used to read input under your explicit control.
The getline
command is used in several different ways and should
not be used by beginners.
The examples that follow the explanation of the getline
command
include material that has not been covered yet. Therefore, come back
and study the getline
command after you have reviewed the
rest of this Web page and have a good knowledge of how awk
works.
The getline
command returns one if it finds a record and zero if
the end of the file is encountered. If there is some error in getting
a record, such as a file that cannot be opened, then getline
returns -1. In this case, gawk
sets the variable
ERRNO
to a string describing the error that occurred.
In the following examples, command stands for a string value that represents a shell command.
4.8.1 Using getline
with No ArgumentsUsing getline
with no arguments.4.8.2 Using getline
into a VariableUsing getline
into a variable.4.8.3 Using getline
from a FileUsing getline
from a file.4.8.4 Using getline
into a Variable from a FileUsing getline
into a variable from a file.4.8.5 Using getline
from a PipeUsing getline
from a pipe.4.8.6 Using getline
into a Variable from a PipeUsing getline
into a variable from a pipe.4.8.7 Using getline
from a CoprocessUsing getline
from a coprocess.4.8.8 Using getline
into a Variable from a CoprocessUsing getline
into a variable from a coprocess.4.8.9 Points About getline
to RememberImportant things to know about getline
.4.8.10 Summary of getline
Variants
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |