Go to the first, previous, next, last section, table of contents.


I/O Statements

The Input/Output statements are as follows:

getline
Set $0 from next input record; set NF, NR, FNR. See section Explicit Input with getline.
getline <file
Set $0 from next record of file; set NF.
getline var
Set var from next input record; set NR, FNR.
getline var <file
Set var from next record of file.
command | getline
Run command, piping its output into getline; sets $0, NF, NR.
command | getline var
Run command, piping its output into getline; sets var.
next
Stop processing the current input record. The next input record is read and processing starts over with the first pattern in the awk program. If the end of the input data is reached, the END rule(s), if any, are executed. See section The next Statement.
nextfile
Stop processing the current input file. The next input record read comes from the next input file. FILENAME is updated, FNR is set to one, ARGIND is incremented, and processing starts over with the first pattern in the awk program. If the end of the input data is reached, the END rule(s), if any, are executed. Earlier versions of gawk used `next file'; this usage is still supported, but is considered to be deprecated. See section The nextfile Statement.
print
Prints the current record. See section Printing Output.
print expr-list
Prints expressions.
print expr-list > file
Prints expressions to file. If file does not exist, it is created. If it does exist, its contents are deleted the first time the print is executed.
print expr-list >> file
Prints expressions to file. The previous contents of file are retained, and the output of print is appended to the file.
print expr-list | command
Prints expressions, sending the output down a pipe to command. The pipeline to the command stays open until the close function is called.
printf fmt, expr-list
Format and print.
printf fmt, expr-list > file
Format and print to file. If file does not exist, it is created. If it does exist, its contents are deleted the first time the printf is executed.
printf fmt, expr-list >> file
Format and print to file. The previous contents of file are retained, and the output of printf is appended to the file.
printf fmt, expr-list | command
Format and print, sending the output down a pipe to command. The pipeline to the command stays open until the close function is called.

getline returns zero on end of file, and -1 on an error. In the event of an error, getline will set ERRNO to the value of a system-dependent string that describes the error.


Go to the first, previous, next, last section, table of contents.