getline
[var] [<
file] | getline
[var]Read next line of input. Original awk doesn't support the syntax to open multiple input streams. The first form reads input from file; the second form reads the output of command. Both forms read one record at a time, and each time the statement is executed, it gets the next record of input. The record is assigned to $0
and is parsed into fields, setting NF
, NR
and FNR
. If var is specified, the result is assigned to var, and $0
and NF
aren't changed. Thus, if the result is assigned to a variable, the current record doesn't change. getline
is actually a function and returns 1 if it reads a record successfully, 0 if end-of-file is encountered, and -1 if it's otherwise unsuccessful. {N}