The >
sign is testing the return value from getline
(for greater than zero). It is not a redirection sign.
From https://www.gnu.org/software/gawk/manual/html_node/Getline.html :
The getline command returns one if it finds a record and zero if it encounters the end of the file. 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.
The confusion may come from the fact that output redirection to a file is not used by getline
. (It is used only to read data). So there should be no ambiguity regarding the >
sign. (It cannot mean output redirection)
To print something to a file you can use output redirection from the print
or printf
commands.