
784
|
Chapter 11: The gawk Programming Language
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
function
function name(parameter-list) {
statements
}
Create name as a user-defined function consisting of awk state-
ments that apply to the specified list of parameters. No space is
allowed between name and the left parenthesis when the function
is called.
gensub
gensub(regex, str, how [, target]) {G}
General substitution function. Substitute str for matches of the
regular expression regex in the string target.Ifhow is a number,
replace the howth match. If it is "g" or "G", substitute globally. If
target is not supplied, $0 is used. Return the new string value. The
original target is not modified. (Compare with gsub and sub.) Use
& in the replacement string to stand for the text matched by the
pattern.
getline
getline
getline [var] [< file]
command | getline [var]
command |& getline [var] {G}
Read next line of input.
The second form reads input from file, and the third form reads the
output of command. All 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 are not changed. Thus, if the result is assigned to a variable, the
current record does not change. ...