gawk: Getline

1 
1 4.10 Explicit Input with 'getline'
1 ==================================
1 
1 So far we have been getting our input data from 'awk''s main input
1 stream--either the standard input (usually your keyboard, sometimes the
1 output from another program) or the files specified on the command line.
1 The 'awk' language has a special built-in command called 'getline' that
1 can be used to read input under your explicit control.
1 
1    The 'getline' command is used in several different ways and should
1 _not_ be used by beginners.  The examples that follow the explanation of
1 the 'getline' command include material that has not been covered yet.
1 Therefore, come back and study the 'getline' command _after_ you have
1 reviewed the rest of this Info file and have a good knowledge of how
1 'awk' works.
1 
1    The 'getline' command returns 1 if it finds a record and 0 if it
1 encounters the end of the file.  If there is some error in getting a
1 record, such as a file that cannot be opened, then 'getline' returns -1.
1 In this case, 'gawk' sets the variable 'ERRNO' to a string describing
1 the error that occurred.
1 
1    If 'ERRNO' indicates that the I/O operation may be retried, and
1 'PROCINFO["INPUT", "RETRY"]' is set, then 'getline' returns -2 instead
11 of -1, and further calls to 'getline' may be attempted.  ⇒Retrying
 Input for further information about this feature.
1 
1    In the following examples, COMMAND stands for a string value that
1 represents a shell command.
1 
1      NOTE: When '--sandbox' is specified (⇒Options), reading
1      lines from files, pipes, and coprocesses is disabled.
1 

Menu