16.12.2012 Views

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

awk<br />

contains five fields, two of which contain only blanks. With the default setting, this<br />

record only contains three fields, since awk considers the sequence of multiple<br />

blanks and tabs a single separator.<br />

The following list of built-in variables provides various pieces of information about<br />

input:<br />

NF Number of fields in the current record<br />

NR Number of records read so far<br />

FILENAME Name of file containing current record<br />

FNR Number of records read from current file<br />

Field specifiers have the form $n, where n runs from 1 through NF. Such a field<br />

specifier refers to the nth field of the current input record. $0 (zero) refers to the<br />

entire current input record.<br />

The getline function can read a value for a variable or $0 from the current input,<br />

from a file, or from a pipe. The result of getline is an integer indicating whether the<br />

read operation was successful. A value of 1 indicates success; 0 indicates that the<br />

end of the file was encountered; and −1 indicates that an error occurred. Possible<br />

forms for getline are:<br />

getline<br />

Reads next input record into $0 and splits the record into fields. NF, NR,<br />

and FNR are set appropriately.<br />

getline var<br />

Reads the next input record into the variable var. awk does not split the<br />

record into fields (which means that the current $n values do not change),<br />

but sets NR and FNR appropriately.<br />

getline in<br />

print or printf.<br />

If the function successfully closes the pipe, it returns zero. By closing files and<br />

pipes that you no longer need, you can use any number of files and pipes in the<br />

course of running an awk program.<br />

38 z/<strong>OS</strong> <strong>V1R9.0</strong> <strong>UNIX</strong> <strong>System</strong> <strong>Services</strong> <strong>Command</strong> Reference

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!