getline

Last edit

Summary: wiki syntax fixes

Changed:

< === _Failure_
< If a [failure] occurs during the [getline] operation, the special variable [ERRNO] should becomes set and the [awk] script should [abort] with a [fatal] error. However, some versions of [awk] do not [abort] following the [failure] of [getline].

to

> === Failure ===
> If a [[failure]] occurs during the [[getline]] operation, the special variable [[ERRNO]] should becomes set and the [[awk]] script should [[abort]] with a [[fatal]] error. However, some versions of [[awk]] do not [[abort]] following the [[failure]] of [[getline]].

Changed:

< The getline function does not have a corresponding '''putline''' function. In [[awk]], output to a specific file is achieved by using [redirection].

to

> The getline function does not have a corresponding '''putline''' function. In [[awk]], output to a specific file is achieved by using [[redirection]].


The *getline* command can obtain input from any number of files and does not require a command line parameter to be provided for the [filename]. The following summarises six variants of getline applications, listing which variables are set by each one:

*Variant**Variables Set*
getline $0, ${1...NF}, NF, FNR, NR, FILENAME
getline foobar foobar, FNR, NR, FILENAME
getline < foobar.txt $0, ${1...NF}, NF
getline foobar < foobar.txt foobar
foo | getline$0, ${1...NF}, NF
foo | getline foobar foobar

Failure

If a [[failure?]] occurs during the getline operation, the special variable [[ERRNO?]] should becomes set and the awk script should [[abort?]] with a [[fatal?]] error. However, some versions of awk do not [[abort?]] following the [[failure?]] of getline.

_There is no corresponding putline_

The getline function does not have a corresponding '''putline''' function. In awk, output to a specific file is achieved by using redirection.