diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/ChangeLog | 4 | ||||
-rw-r--r-- | doc/gawk.info | 1193 | ||||
-rw-r--r-- | doc/gawk.texi | 93 | ||||
-rw-r--r-- | doc/gawktexi.in | 93 |
4 files changed, 669 insertions, 714 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index 01da6377..ae380bbd 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2014-08-23 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in: Continuing on reviewer comments. + 2014-08-22 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Continuing on reviewer comments. diff --git a/doc/gawk.info b/doc/gawk.info index 05434558..631a1fa0 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -2243,9 +2243,7 @@ edit-compile-test-debug cycle of software development. retargetable assembler for eight-bit microprocessors (*note Glossary::, for more information), and a microcode assembler for a special-purpose Prolog computer. While the original `awk''s capabilities were strained -by tasks of such complexity, modern versions are more capable. Even -BWK `awk' has fewer predefined limits, and those that it has are much -larger than they used to be. +by tasks of such complexity, modern versions are more capable. If you find yourself writing `awk' scripts of more than, say, a few hundred lines, you might consider using a different programming @@ -2266,6 +2264,9 @@ File: gawk.info, Node: Intro Summary, Prev: When, Up: Getting Started * Programs in `awk' consist of PATTERN-ACTION pairs. + * An ACTION without a PATTERN always runs. The default ACTION for a + pattern without one is `{ print $0 }'. + * Use either `awk 'PROGRAM' FILES' or `awk -f PROGRAM-FILE FILES' to run `awk'. @@ -3200,7 +3201,7 @@ that matches every input record whose text belongs to that set. The simplest regular expression is a sequence of letters, numbers, or both. Such a regexp matches any string that contains that sequence. Thus, the regexp `foo' matches any string containing `foo'. Therefore, the -pattern `/foo/' matches any input record containing the three +pattern `/foo/' matches any input record containing the three adjacent characters `foo' _anywhere_ in the record. Other kinds of regexps let you specify more complicated classes of strings. @@ -3497,9 +3498,10 @@ sequences and that are not listed in the table stand for themselves: `|' This is the "alternation operator" and it is used to specify alternatives. The `|' has the lowest precedence of all the regular - expression operators. For example, `^P|[[:digit:]]' matches any - string that matches either `^P' or `[[:digit:]]'. This means it - matches any string that starts with `P' or contains a digit. + expression operators. For example, `^P|[aeiouy]' matches any + string that matches either `^P' or `[aeiouy]'. This means it + matches any string that starts with `P' or contains (anywhere + within it) a lowercase English vowel. The alternation applies to the largest possible regexps on either side. @@ -3625,7 +3627,9 @@ expression, put a `\' in front of it. For example: [d\]] -matches either `d' or `]'. +matches either `d' or `]'. Additionally, if you place `]' right after +the opening `[', the closing bracket is treated as one of the +characters to be matched. This treatment of `\' in bracket expressions is compatible with other `awk' implementations and is also mandated by POSIX. The regular @@ -4020,7 +4024,7 @@ File: gawk.info, Node: Regexp Summary, Prev: Computed Regexps, Up: Regexp extent of the match, such as for text substitution and when the record separator is a regexp. - * Matching expressions may use dynamic regexps; that is, string + * Matching expressions may use dynamic regexps, that is, string values treated as regular expressions. @@ -4073,13 +4077,13 @@ File: gawk.info, Node: Records, Next: Fields, Up: Reading Files 4.1 How Input Is Split into Records =================================== -The `awk' utility divides the input for your `awk' program into records -and fields. `awk' keeps track of the number of records that have been -read so far from the current input file. This value is stored in a -built-in variable called `FNR'. It is reset to zero when a new file is -started. Another built-in variable, `NR', records the total number of -input records read so far from all data files. It starts at zero, but -is never automatically reset to zero. +`awk' divides the input for your program into records and fields. It +keeps track of the number of records that have been read so far from +the current input file. This value is stored in a built-in variable +called `FNR' which is reset to zero when a new file is started. +Another built-in variable, `NR', records the total number of input +records read so far from all data files. It starts at zero, but is +never automatically reset to zero. * Menu: @@ -5334,8 +5338,8 @@ yet. Therefore, come back and study the `getline' command _after_ you have reviewed the rest of this Info file and have a good knowledge of how `awk' works. - 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 + The `getline' command returns 1 if it finds a record and 0 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. @@ -8436,9 +8440,9 @@ because of the way they work. Evaluation of the full expression is "short-circuited" if the result can be determined part way through its evaluation. - Statements that use `&&' or `||' can be continued simply by putting -a newline after them. But you cannot put a newline in front of either -of these operators without using backslash continuation (*note + Statements that end with `&&' or `||' can be continued simply by +putting a newline after them. But you cannot put a newline in front of +either of these operators without using backslash continuation (*note Statements/Lines::). The actual value of an expression using the `!' operator is either @@ -8914,7 +8918,7 @@ precisely `li': `li'.) Contrast this with the following regular expression match, which accepts any record with a first field that contains `li': - $ awk '$1 ~ /foo/ { print $2 }' mail-list + $ awk '$1 ~ /li/ { print $2 }' mail-list -| 555-5553 -| 555-6699 @@ -10805,7 +10809,8 @@ index, use the following expression: This expression tests whether the particular index INDX exists, without the side effect of creating that element if it is not present. The expression has the value one (true) if `ARRAY[INDX]' exists and zero -(false) if it does not exist. For example, this statement tests +(false) if it does not exist. (We use INDX here, since `index' is the +name of a built-in function.) For example, this statement tests whether the array `frequencies' contains the index `2': if (2 in frequencies) @@ -14669,8 +14674,7 @@ worrying about: } #### test code #### - # BEGIN \ - # { + # BEGIN { # for (;;) { # printf("enter a character: ") # if (getline var <= 0) @@ -15793,8 +15797,7 @@ the same names: # group.awk --- functions for dealing with the group file - BEGIN \ - { + BEGIN { # Change to suit your system _gr_awklib = "/usr/local/libexec/awk/" } @@ -16217,8 +16220,7 @@ through the command-line options. Exactly one of the variables should be done by fields or by characters, respectively. When cutting by characters, the output field separator is set to the null string: - BEGIN \ - { + BEGIN { FS = "\t" # default OFS = FS while ((c = getopt(ARGC, ARGV, "sf:c:d:")) != -1) { @@ -16603,8 +16605,7 @@ line is printed, with a leading file name and colon if necessary: The `END' rule takes care of producing the correct exit status. If there are no matches, the exit status is one; otherwise it is zero: - END \ - { + END { exit (total == 0) } @@ -16622,13 +16623,6 @@ options, and then exits: The variable `e' is used so that the function fits nicely on the printed page. - Just a note on programming style: you may have noticed that the `END' -rule uses backslash continuation, with the open brace on a line by -itself. This is so that it more closely resembles the way functions -are written. Many of the examples in this major node use this style. -You can decide for yourself if you like writing your `BEGIN' and `END' -rules this way or not. - ---------- Footnotes ---------- (1) It also introduces a subtle bug; if a match happens, we output @@ -16671,8 +16665,7 @@ and the group numbers: # uid=12(foo) euid=34(bar) gid=3(baz) \ # egid=5(blat) groups=9(nine),2(two),1(one) - BEGIN \ - { + BEGIN { uid = PROCINFO["uid"] euid = PROCINFO["euid"] gid = PROCINFO["gid"] @@ -16880,8 +16873,7 @@ input by setting `ARGV[1]' to `"-"' and `ARGC' to two: # Copy standard input to all named output files. # Append content if -a option is supplied. # - BEGIN \ - { + BEGIN { for (i = 1; i < ARGC; i++) copy[i] = ARGV[i] @@ -16931,8 +16923,7 @@ N input records and M output files, the first method only executes N Finally, the `END' rule cleans up by closing all the output files: - END \ - { + END { for (i in copy) close(copy[i]) } @@ -17019,8 +17010,7 @@ standard output, `/dev/stdout': # -n skip n fields # +n skip n characters, skip fields first - BEGIN \ - { + BEGIN { count = 1 outputfile = "/dev/stdout" opts = "udc0:1:2:3:4:5:6:7:8:9:" @@ -17408,8 +17398,7 @@ Statement::), but the processing could be done with a series of # Requires getlocaltime() library function # usage: alarm time [ "message" [ count [ delay ] ] ] - BEGIN \ - { + BEGIN { # Initial argument sanity checking usage1 = "usage: alarm time ['message' [count [delay]]]" usage2 = sprintf("\t(%s) time ::= hh:mm", ARGV[1]) @@ -17730,8 +17719,7 @@ not have been an even multiple of 20 labels in the data: Count++ } - END \ - { + END { printpage() } @@ -31004,11 +30992,11 @@ Index * ' (single quote), vs. apostrophe: Comments. (line 27) * ' (single quote), with double quotes: Quoting. (line 70) * () (parentheses), in a profile: Profiling. (line 146) -* () (parentheses), regexp operator: Regexp Operators. (line 80) +* () (parentheses), regexp operator: Regexp Operators. (line 81) * * (asterisk), * operator, as multiplication operator: Precedence. (line 55) * * (asterisk), * operator, as regexp operator: Regexp Operators. - (line 88) + (line 89) * * (asterisk), * operator, null strings, matching: Gory Details. (line 143) * * (asterisk), ** operator <1>: Precedence. (line 49) @@ -31022,7 +31010,7 @@ Index * + (plus sign), ++ operator: Increment Ops. (line 11) * + (plus sign), += operator <1>: Precedence. (line 95) * + (plus sign), += operator: Assignment Ops. (line 82) -* + (plus sign), regexp operator: Regexp Operators. (line 103) +* + (plus sign), regexp operator: Regexp Operators. (line 104) * , (comma), in range patterns: Ranges. (line 6) * - (hyphen), - operator: Precedence. (line 52) * - (hyphen), -- operator <1>: Precedence. (line 46) @@ -31165,7 +31153,7 @@ Index * ? (question mark), ?: operator: Precedence. (line 92) * ? (question mark), regexp operator <1>: GNU Regexp Operators. (line 59) -* ? (question mark), regexp operator: Regexp Operators. (line 112) +* ? (question mark), regexp operator: Regexp Operators. (line 113) * [] (square brackets), regexp operator: Regexp Operators. (line 56) * \ (backslash): Comments. (line 50) * \ (backslash) in shell commands: Read Terminal. (line 25) @@ -31202,7 +31190,6 @@ Index (line 38) * \ (backslash), as field separator: Command Line Field Separator. (line 27) -* \ (backslash), continuing lines and <1>: Egrep Program. (line 223) * \ (backslash), continuing lines and: Statements/Lines. (line 19) * \ (backslash), continuing lines and, comments and: Statements/Lines. (line 76) @@ -31368,7 +31355,7 @@ Index * asterisk (*), * operator, as multiplication operator: Precedence. (line 55) * asterisk (*), * operator, as regexp operator: Regexp Operators. - (line 88) + (line 89) * asterisk (*), * operator, null strings, matching: Gory Details. (line 143) * asterisk (*), ** operator <1>: Precedence. (line 49) @@ -31386,7 +31373,7 @@ Index * awk programs <1>: Two Rules. (line 6) * awk programs <2>: Executable Scripts. (line 6) * awk programs: Getting Started. (line 12) -* awk programs, complex: When. (line 29) +* awk programs, complex: When. (line 27) * awk programs, documenting <1>: Library Names. (line 6) * awk programs, documenting: Comments. (line 6) * awk programs, examples of: Sample Programs. (line 6) @@ -31475,7 +31462,6 @@ Index (line 38) * backslash (\), as field separator: Command Line Field Separator. (line 27) -* backslash (\), continuing lines and <1>: Egrep Program. (line 223) * backslash (\), continuing lines and: Statements/Lines. (line 19) * backslash (\), continuing lines and, comments and: Statements/Lines. (line 76) @@ -31551,15 +31537,15 @@ Index * bracket expressions <1>: Bracket Expressions. (line 6) * bracket expressions: Regexp Operators. (line 56) * bracket expressions, character classes: Bracket Expressions. - (line 30) + (line 32) * bracket expressions, collating elements: Bracket Expressions. - (line 77) + (line 79) * bracket expressions, collating symbols: Bracket Expressions. - (line 84) + (line 86) * bracket expressions, complemented: Regexp Operators. (line 64) * bracket expressions, equivalence classes: Bracket Expressions. - (line 90) -* bracket expressions, non-ASCII: Bracket Expressions. (line 77) + (line 92) +* bracket expressions, non-ASCII: Bracket Expressions. (line 79) * bracket expressions, range expressions: Bracket Expressions. (line 6) * break debugger command: Breakpoint Control. (line 11) @@ -31676,8 +31662,8 @@ Index * Close, Diane <1>: Contributors. (line 20) * Close, Diane: Manual History. (line 34) * Collado, Manuel: Acknowledgments. (line 60) -* collating elements: Bracket Expressions. (line 77) -* collating symbols: Bracket Expressions. (line 84) +* collating elements: Bracket Expressions. (line 79) +* collating symbols: Bracket Expressions. (line 86) * Colombo, Antonio <1>: Contributors. (line 137) * Colombo, Antonio: Acknowledgments. (line 60) * columns, aligning: Print Examples. (line 70) @@ -32101,7 +32087,7 @@ Index * effective group ID of gawk user: Auto-set. (line 141) * effective user ID of gawk user: Auto-set. (line 145) * egrep utility <1>: Egrep Program. (line 6) -* egrep utility: Bracket Expressions. (line 24) +* egrep utility: Bracket Expressions. (line 26) * egrep.awk program: Egrep Program. (line 54) * elements in arrays, assigning values: Assigning Elements. (line 6) * elements in arrays, deleting: Delete. (line 6) @@ -32127,7 +32113,6 @@ Index * END pattern, and profiling: Profiling. (line 62) * END pattern, assert() user-defined function and: Assert Function. (line 75) -* END pattern, backslash continuation and: Egrep Program. (line 223) * END pattern, Boolean patterns and: Expression Patterns. (line 70) * END pattern, exit statement and: Exit Statement. (line 12) * END pattern, next/nextfile statements and <1>: Next Statement. @@ -32139,8 +32124,8 @@ Index * ENDFILE pattern: BEGINFILE/ENDFILE. (line 6) * ENDFILE pattern, Boolean patterns and: Expression Patterns. (line 70) * endfile() user-defined function: Filetrans Function. (line 62) -* endgrent() function (C library): Group Functions. (line 213) -* endgrent() user-defined function: Group Functions. (line 216) +* endgrent() function (C library): Group Functions. (line 212) +* endgrent() user-defined function: Group Functions. (line 215) * endpwent() function (C library): Passwd Functions. (line 210) * endpwent() user-defined function: Passwd Functions. (line 213) * English, Steve: Advanced Features. (line 6) @@ -32153,7 +32138,7 @@ Index * equals sign (=), == operator <1>: Precedence. (line 65) * equals sign (=), == operator: Comparison Operators. (line 11) -* EREs (Extended Regular Expressions): Bracket Expressions. (line 24) +* EREs (Extended Regular Expressions): Bracket Expressions. (line 26) * ERRNO variable <1>: TCP/IP Networking. (line 54) * ERRNO variable: Auto-set. (line 82) * ERRNO variable, with BEGINFILE pattern: BEGINFILE/ENDFILE. (line 26) @@ -32208,7 +32193,7 @@ Index * expressions, matching, See comparison expressions: Typing and Comparison. (line 9) * expressions, selecting: Conditional Exp. (line 6) -* Extended Regular Expressions (EREs): Bracket Expressions. (line 24) +* Extended Regular Expressions (EREs): Bracket Expressions. (line 26) * extension API: Extension API Description. (line 6) * extension API informational variables: Extension API Informational Variables. @@ -32274,7 +32259,7 @@ Index (line 6) * field separators, regular expressions as: Field Separators. (line 51) * field separators, See Also OFS: Changing Fields. (line 64) -* field separators, spaces as: Cut Program. (line 109) +* field separators, spaces as: Cut Program. (line 108) * fields <1>: Basic High Level. (line 73) * fields <2>: Fields. (line 6) * fields: Reading Files. (line 14) @@ -32471,7 +32456,7 @@ Index * gawk, bitwise operations in: Bitwise Functions. (line 39) * gawk, break statement in: Break Statement. (line 51) * gawk, built-in variables and: Built-in Variables. (line 14) -* gawk, character classes and: Bracket Expressions. (line 98) +* gawk, character classes and: Bracket Expressions. (line 100) * gawk, coding style in: Adding Code. (line 39) * gawk, command-line options, and regular expressions: GNU Regexp Operators. (line 70) @@ -32522,7 +32507,7 @@ Index (line 13) * gawk, interpreter, adding code to: Using Internal File Ops. (line 6) -* gawk, interval expressions and: Regexp Operators. (line 140) +* gawk, interval expressions and: Regexp Operators. (line 141) * gawk, line continuation in: Conditional Exp. (line 34) * gawk, LINT variable in: User-modified. (line 88) * gawk, list of contributors to: Contributors. (line 6) @@ -32540,7 +32525,7 @@ Index (line 26) * gawk, regular expressions, operators: GNU Regexp Operators. (line 6) -* gawk, regular expressions, precedence: Regexp Operators. (line 162) +* gawk, regular expressions, precedence: Regexp Operators. (line 163) * gawk, RT variable in <1>: Auto-set. (line 265) * gawk, RT variable in <2>: Multiple Line. (line 129) * gawk, RT variable in: awk split records. (line 124) @@ -32568,12 +32553,12 @@ Index * getaddrinfo() function (C library): TCP/IP Networking. (line 38) * getgrent() function (C library): Group Functions. (line 6) * getgrent() user-defined function: Group Functions. (line 6) -* getgrgid() function (C library): Group Functions. (line 184) -* getgrgid() user-defined function: Group Functions. (line 187) -* getgrnam() function (C library): Group Functions. (line 173) -* getgrnam() user-defined function: Group Functions. (line 178) -* getgruser() function (C library): Group Functions. (line 193) -* getgruser() function, user-defined: Group Functions. (line 196) +* getgrgid() function (C library): Group Functions. (line 183) +* getgrgid() user-defined function: Group Functions. (line 186) +* getgrnam() function (C library): Group Functions. (line 172) +* getgrnam() user-defined function: Group Functions. (line 177) +* getgruser() function (C library): Group Functions. (line 192) +* getgruser() function, user-defined: Group Functions. (line 195) * getline command: Reading Files. (line 20) * getline command, _gr_init() user-defined function: Group Functions. (line 83) @@ -32747,7 +32732,7 @@ Index (line 13) * internationalization, localization: User-modified. (line 152) * internationalization, localization, character classes: Bracket Expressions. - (line 98) + (line 100) * internationalization, localization, gawk and: Internationalization. (line 13) * internationalization, localization, locale categories: Explaining gettext. @@ -32759,7 +32744,7 @@ Index * internationalizing a program: Explaining gettext. (line 6) * interpreted programs <1>: Glossary. (line 356) * interpreted programs: Basic High Level. (line 15) -* interval expressions, regexp operator: Regexp Operators. (line 117) +* interval expressions, regexp operator: Regexp Operators. (line 118) * inventory-shipped file: Sample Data Files. (line 32) * invoke shell command: I/O Functions. (line 75) * isarray: Type Functions. (line 11) @@ -33117,7 +33102,7 @@ Index * Papadopoulos, Panos: Contributors. (line 128) * parent process ID of gawk process: Auto-set. (line 189) * parentheses (), in a profile: Profiling. (line 146) -* parentheses (), regexp operator: Regexp Operators. (line 80) +* parentheses (), regexp operator: Regexp Operators. (line 81) * password file: Passwd Functions. (line 16) * patsplit: String Functions. (line 294) * patterns: Patterns and Actions. @@ -33155,7 +33140,7 @@ Index * plus sign (+), ++ operator: Increment Ops. (line 11) * plus sign (+), += operator <1>: Precedence. (line 95) * plus sign (+), += operator: Assignment Ops. (line 82) -* plus sign (+), regexp operator: Regexp Operators. (line 103) +* plus sign (+), regexp operator: Regexp Operators. (line 104) * pointers to functions: Indirect Calls. (line 6) * portability: Escape Sequences. (line 100) * portability, #! (executable scripts): Executable Scripts. (line 33) @@ -33205,9 +33190,9 @@ Index * POSIX awk, backslashes in string constants: Escape Sequences. (line 118) * POSIX awk, BEGIN/END patterns: I/O And BEGIN/END. (line 16) -* POSIX awk, bracket expressions and: Bracket Expressions. (line 24) +* POSIX awk, bracket expressions and: Bracket Expressions. (line 26) * POSIX awk, bracket expressions and, character classes: Bracket Expressions. - (line 30) + (line 32) * POSIX awk, break statement and: Break Statement. (line 51) * POSIX awk, changes in awk versions: POSIX. (line 6) * POSIX awk, continue statement and: Continue Statement. (line 44) @@ -33221,14 +33206,14 @@ Index * POSIX awk, functions and, gsub()/sub(): Gory Details. (line 90) * POSIX awk, functions and, length(): String Functions. (line 176) * POSIX awk, GNU long options and: Options. (line 15) -* POSIX awk, interval expressions in: Regexp Operators. (line 136) +* POSIX awk, interval expressions in: Regexp Operators. (line 137) * POSIX awk, next/nextfile statements and: Next Statement. (line 45) * POSIX awk, numeric strings and: Variable Typing. (line 6) * POSIX awk, OFMT variable and <1>: Strings And Numbers. (line 57) * POSIX awk, OFMT variable and: OFMT. (line 27) * POSIX awk, period (.), using: Regexp Operators. (line 51) * POSIX awk, printf format strings and: Format Modifiers. (line 159) -* POSIX awk, regular expressions and: Regexp Operators. (line 162) +* POSIX awk, regular expressions and: Regexp Operators. (line 163) * POSIX awk, timestamps and: Time Functions. (line 6) * POSIX awk, | I/O operator and: Getline/Pipe. (line 55) * POSIX mode: Options. (line 252) @@ -33239,7 +33224,7 @@ Index * PREC variable: User-modified. (line 124) * precedence <1>: Precedence. (line 6) * precedence: Increment Ops. (line 60) -* precedence, regexp operators: Regexp Operators. (line 157) +* precedence, regexp operators: Regexp Operators. (line 158) * print debugger command: Viewing And Changing Data. (line 36) * print statement: Printing. (line 16) @@ -33326,7 +33311,7 @@ Index * question mark (?), ?: operator: Precedence. (line 92) * question mark (?), regexp operator <1>: GNU Regexp Operators. (line 59) -* question mark (?), regexp operator: Regexp Operators. (line 112) +* question mark (?), regexp operator: Regexp Operators. (line 113) * QuikTrim Awk: Other Versions. (line 135) * quit debugger command: Miscellaneous Debugger Commands. (line 99) @@ -33426,7 +33411,7 @@ Index * regular expressions, operators, gawk: GNU Regexp Operators. (line 6) * regular expressions, operators, precedence of: Regexp Operators. - (line 157) + (line 158) * regular expressions, searching for: Egrep Program. (line 6) * relational operators, See comparison operators: Typing and Comparison. (line 9) @@ -33636,7 +33621,7 @@ Index * single-step execution, in the debugger: Debugger Execution Control. (line 43) * Skywalker, Luke: Undocumented. (line 6) -* sleep utility: Alarm Program. (line 111) +* sleep utility: Alarm Program. (line 110) * sleep() extension function: Extension Sample Time. (line 22) * Solaris, POSIX-compliant awk: Other Versions. (line 96) @@ -34056,516 +34041,516 @@ Node: Statements/Lines102442 Ref: Statements/Lines-Footnote-1106898 Node: Other Features107163 Node: When108091 -Ref: When-Footnote-1109952 -Node: Intro Summary110017 -Node: Invoking Gawk110783 -Node: Command Line112298 -Node: Options113089 -Ref: Options-Footnote-1128736 -Node: Other Arguments128761 -Node: Naming Standard Input131423 -Node: Environment Variables132516 -Node: AWKPATH Variable133074 -Ref: AWKPATH Variable-Footnote-1135940 -Ref: AWKPATH Variable-Footnote-2135985 -Node: AWKLIBPATH Variable136245 -Node: Other Environment Variables137004 -Node: Exit Status140456 -Node: Include Files141131 -Node: Loading Shared Libraries144709 -Node: Obsolete146093 -Node: Undocumented146790 -Node: Invoking Summary147057 -Node: Regexp148657 -Node: Regexp Usage150107 -Node: Escape Sequences152140 -Node: Regexp Operators158040 -Ref: Regexp Operators-Footnote-1165520 -Ref: Regexp Operators-Footnote-2165667 -Node: Bracket Expressions165765 -Ref: table-char-classes167655 -Node: GNU Regexp Operators170595 -Node: Case-sensitivity174304 -Ref: Case-sensitivity-Footnote-1177196 -Ref: Case-sensitivity-Footnote-2177431 -Node: Leftmost Longest177539 -Node: Computed Regexps178740 -Node: Regexp Summary182112 -Node: Reading Files183581 -Node: Records185673 -Node: awk split records186416 -Node: gawk split records191274 -Ref: gawk split records-Footnote-1195795 -Node: Fields195832 -Ref: Fields-Footnote-1198796 -Node: Nonconstant Fields198882 -Ref: Nonconstant Fields-Footnote-1201112 -Node: Changing Fields201314 -Node: Field Separators207268 -Node: Default Field Splitting209970 -Node: Regexp Field Splitting211087 -Node: Single Character Fields214414 -Node: Command Line Field Separator215473 -Node: Full Line Fields218899 -Ref: Full Line Fields-Footnote-1219407 -Node: Field Splitting Summary219453 -Ref: Field Splitting Summary-Footnote-1222585 -Node: Constant Size222686 -Node: Splitting By Content227292 -Ref: Splitting By Content-Footnote-1231365 -Node: Multiple Line231405 -Ref: Multiple Line-Footnote-1237261 -Node: Getline237440 -Node: Plain Getline239656 -Node: Getline/Variable241751 -Node: Getline/File242898 -Node: Getline/Variable/File244282 -Ref: Getline/Variable/File-Footnote-1245881 -Node: Getline/Pipe245968 -Node: Getline/Variable/Pipe248654 -Node: Getline/Coprocess249761 -Node: Getline/Variable/Coprocess251013 -Node: Getline Notes251750 -Node: Getline Summary254554 -Ref: table-getline-variants254962 -Node: Read Timeout255874 -Ref: Read Timeout-Footnote-1259701 -Node: Command-line directories259759 -Node: Input Summary260663 -Node: Input Exercises263800 -Node: Printing264533 -Node: Print266255 -Node: Print Examples267748 -Node: Output Separators270527 -Node: OFMT272543 -Node: Printf273901 -Node: Basic Printf274807 -Node: Control Letters276346 -Node: Format Modifiers280337 -Node: Printf Examples286364 -Node: Redirection288828 -Node: Special Files295800 -Node: Special FD296333 -Ref: Special FD-Footnote-1299930 -Node: Special Network300004 -Node: Special Caveats300854 -Node: Close Files And Pipes301650 -Ref: Close Files And Pipes-Footnote-1308811 -Ref: Close Files And Pipes-Footnote-2308959 -Node: Output Summary309109 -Node: Output exercises310106 -Node: Expressions310786 -Node: Values311971 -Node: Constants312647 -Node: Scalar Constants313327 -Ref: Scalar Constants-Footnote-1314186 -Node: Nondecimal-numbers314436 -Node: Regexp Constants317436 -Node: Using Constant Regexps317911 -Node: Variables320983 -Node: Using Variables321638 -Node: Assignment Options323362 -Node: Conversion325237 -Node: Strings And Numbers325761 -Ref: Strings And Numbers-Footnote-1328823 -Node: Locale influences conversions328932 -Ref: table-locale-affects331649 -Node: All Operators332237 -Node: Arithmetic Ops332867 -Node: Concatenation335372 -Ref: Concatenation-Footnote-1338191 -Node: Assignment Ops338297 -Ref: table-assign-ops343280 -Node: Increment Ops344583 -Node: Truth Values and Conditions348021 -Node: Truth Values349104 -Node: Typing and Comparison350153 -Node: Variable Typing350946 -Node: Comparison Operators354598 -Ref: table-relational-ops355008 -Node: POSIX String Comparison358558 -Ref: POSIX String Comparison-Footnote-1359642 -Node: Boolean Ops359780 -Ref: Boolean Ops-Footnote-1363850 -Node: Conditional Exp363941 -Node: Function Calls365668 -Node: Precedence369548 -Node: Locales373217 -Node: Expressions Summary374848 -Node: Patterns and Actions377389 -Node: Pattern Overview378505 -Node: Regexp Patterns380182 -Node: Expression Patterns380725 -Node: Ranges384506 -Node: BEGIN/END387612 -Node: Using BEGIN/END388374 -Ref: Using BEGIN/END-Footnote-1391110 -Node: I/O And BEGIN/END391216 -Node: BEGINFILE/ENDFILE393487 -Node: Empty396418 -Node: Using Shell Variables396735 -Node: Action Overview399018 -Node: Statements401345 -Node: If Statement403193 -Node: While Statement404691 -Node: Do Statement406735 -Node: For Statement407891 -Node: Switch Statement411043 -Node: Break Statement413431 -Node: Continue Statement415472 -Node: Next Statement417297 -Node: Nextfile Statement419687 -Node: Exit Statement422323 -Node: Built-in Variables424727 -Node: User-modified425854 -Ref: User-modified-Footnote-1433543 -Node: Auto-set433605 -Ref: Auto-set-Footnote-1446524 -Ref: Auto-set-Footnote-2446729 -Node: ARGC and ARGV446785 -Node: Pattern Action Summary450689 -Node: Arrays452912 -Node: Array Basics454461 -Node: Array Intro455287 -Ref: figure-array-elements457260 -Node: Reference to Elements459667 -Node: Assigning Elements462046 -Node: Array Example462537 -Node: Scanning an Array464269 -Node: Controlling Scanning467270 -Ref: Controlling Scanning-Footnote-1472443 -Node: Delete472759 -Ref: Delete-Footnote-1475510 -Node: Numeric Array Subscripts475567 -Node: Uninitialized Subscripts477750 -Node: Multidimensional479375 -Node: Multiscanning482488 -Node: Arrays of Arrays484077 -Node: Arrays Summary488740 -Node: Functions490845 -Node: Built-in491718 -Node: Calling Built-in492796 -Node: Numeric Functions494784 -Ref: Numeric Functions-Footnote-1499620 -Ref: Numeric Functions-Footnote-2499977 -Ref: Numeric Functions-Footnote-3500025 -Node: String Functions500294 -Ref: String Functions-Footnote-1523291 -Ref: String Functions-Footnote-2523420 -Ref: String Functions-Footnote-3523668 -Node: Gory Details523755 -Ref: table-sub-escapes525528 -Ref: table-sub-proposed527048 -Ref: table-posix-sub528412 -Ref: table-gensub-escapes529952 -Ref: Gory Details-Footnote-1531128 -Node: I/O Functions531279 -Ref: I/O Functions-Footnote-1538389 -Node: Time Functions538536 -Ref: Time Functions-Footnote-1549000 -Ref: Time Functions-Footnote-2549068 -Ref: Time Functions-Footnote-3549226 -Ref: Time Functions-Footnote-4549337 -Ref: Time Functions-Footnote-5549449 -Ref: Time Functions-Footnote-6549676 -Node: Bitwise Functions549942 -Ref: table-bitwise-ops550504 -Ref: Bitwise Functions-Footnote-1554749 -Node: Type Functions554933 -Node: I18N Functions556075 -Node: User-defined557720 -Node: Definition Syntax558524 -Ref: Definition Syntax-Footnote-1563703 -Node: Function Example563772 -Ref: Function Example-Footnote-1566412 -Node: Function Caveats566434 -Node: Calling A Function566952 -Node: Variable Scope567907 -Node: Pass By Value/Reference570895 -Node: Return Statement574405 -Node: Dynamic Typing577389 -Node: Indirect Calls578318 -Node: Functions Summary588031 -Node: Library Functions590570 -Ref: Library Functions-Footnote-1594188 -Ref: Library Functions-Footnote-2594331 -Node: Library Names594502 -Ref: Library Names-Footnote-1597975 -Ref: Library Names-Footnote-2598195 -Node: General Functions598281 -Node: Strtonum Function599309 -Node: Assert Function602089 -Node: Round Function605415 -Node: Cliff Random Function606956 -Node: Ordinal Functions607972 -Ref: Ordinal Functions-Footnote-1611049 -Ref: Ordinal Functions-Footnote-2611301 -Node: Join Function611512 -Ref: Join Function-Footnote-1613283 -Node: Getlocaltime Function613483 -Node: Readfile Function617219 -Node: Data File Management619058 -Node: Filetrans Function619690 -Node: Rewind Function623759 -Node: File Checking625317 -Ref: File Checking-Footnote-1626449 -Node: Empty Files626650 -Node: Ignoring Assigns628629 -Node: Getopt Function630183 -Ref: Getopt Function-Footnote-1641486 -Node: Passwd Functions641689 -Ref: Passwd Functions-Footnote-1650668 -Node: Group Functions650756 -Ref: Group Functions-Footnote-1658697 -Node: Walking Arrays658910 -Node: Library Functions Summary660513 -Node: Library exercises661901 -Node: Sample Programs663181 -Node: Running Examples663951 -Node: Clones664679 -Node: Cut Program665903 -Node: Egrep Program675771 -Ref: Egrep Program-Footnote-1683742 -Node: Id Program683852 -Node: Split Program687516 -Ref: Split Program-Footnote-1691054 -Node: Tee Program691182 -Node: Uniq Program693989 -Node: Wc Program701419 -Ref: Wc Program-Footnote-1705684 -Node: Miscellaneous Programs705776 -Node: Dupword Program706989 -Node: Alarm Program709020 -Node: Translate Program713834 -Ref: Translate Program-Footnote-1718225 -Ref: Translate Program-Footnote-2718495 -Node: Labels Program718629 -Ref: Labels Program-Footnote-1722000 -Node: Word Sorting722084 -Node: History Sorting726127 -Node: Extract Program727963 -Node: Simple Sed735499 -Node: Igawk Program738561 -Ref: Igawk Program-Footnote-1752865 -Ref: Igawk Program-Footnote-2753066 -Node: Anagram Program753204 -Node: Signature Program756272 -Node: Programs Summary757519 -Node: Programs Exercises758734 -Node: Advanced Features762385 -Node: Nondecimal Data764333 -Node: Array Sorting765910 -Node: Controlling Array Traversal766607 -Node: Array Sorting Functions774887 -Ref: Array Sorting Functions-Footnote-1778794 -Node: Two-way I/O778988 -Ref: Two-way I/O-Footnote-1783932 -Ref: Two-way I/O-Footnote-2784111 -Node: TCP/IP Networking784193 -Node: Profiling787038 -Node: Advanced Features Summary794589 -Node: Internationalization796453 -Node: I18N and L10N797933 -Node: Explaining gettext798619 -Ref: Explaining gettext-Footnote-1803645 -Ref: Explaining gettext-Footnote-2803829 -Node: Programmer i18n803994 -Ref: Programmer i18n-Footnote-1808788 -Node: Translator i18n808837 -Node: String Extraction809631 -Ref: String Extraction-Footnote-1810764 -Node: Printf Ordering810850 -Ref: Printf Ordering-Footnote-1813632 -Node: I18N Portability813696 -Ref: I18N Portability-Footnote-1816145 -Node: I18N Example816208 -Ref: I18N Example-Footnote-1818914 -Node: Gawk I18N818986 -Node: I18N Summary819624 -Node: Debugger820963 -Node: Debugging821985 -Node: Debugging Concepts822426 -Node: Debugging Terms824282 -Node: Awk Debugging826879 -Node: Sample Debugging Session827771 -Node: Debugger Invocation828291 -Node: Finding The Bug829624 -Node: List of Debugger Commands836106 -Node: Breakpoint Control837438 -Node: Debugger Execution Control841102 -Node: Viewing And Changing Data844462 -Node: Execution Stack847820 -Node: Debugger Info849333 -Node: Miscellaneous Debugger Commands853327 -Node: Readline Support858511 -Node: Limitations859403 -Node: Debugging Summary861677 -Node: Arbitrary Precision Arithmetic862845 -Node: Computer Arithmetic864332 -Ref: Computer Arithmetic-Footnote-1868719 -Node: Math Definitions868776 -Ref: table-ieee-formats872065 -Ref: Math Definitions-Footnote-1872605 -Node: MPFR features872708 -Node: FP Math Caution874325 -Ref: FP Math Caution-Footnote-1875375 -Node: Inexactness of computations875744 -Node: Inexact representation876692 -Node: Comparing FP Values878047 -Node: Errors accumulate879011 -Node: Getting Accuracy880444 -Node: Try To Round883103 -Node: Setting precision884002 -Ref: table-predefined-precision-strings884684 -Node: Setting the rounding mode886477 -Ref: table-gawk-rounding-modes886841 -Ref: Setting the rounding mode-Footnote-1890295 -Node: Arbitrary Precision Integers890474 -Ref: Arbitrary Precision Integers-Footnote-1894247 -Node: POSIX Floating Point Problems894396 -Ref: POSIX Floating Point Problems-Footnote-1898272 -Node: Floating point summary898310 -Node: Dynamic Extensions900514 -Node: Extension Intro902066 -Node: Plugin License903331 -Node: Extension Mechanism Outline904016 -Ref: figure-load-extension904440 -Ref: figure-load-new-function905925 -Ref: figure-call-new-function906927 -Node: Extension API Description908911 -Node: Extension API Functions Introduction910361 -Node: General Data Types915228 -Ref: General Data Types-Footnote-1920921 -Node: Requesting Values921220 -Ref: table-value-types-returned921957 -Node: Memory Allocation Functions922915 -Ref: Memory Allocation Functions-Footnote-1925662 -Node: Constructor Functions925758 -Node: Registration Functions927516 -Node: Extension Functions928201 -Node: Exit Callback Functions930503 -Node: Extension Version String931751 -Node: Input Parsers932401 -Node: Output Wrappers942215 -Node: Two-way processors946731 -Node: Printing Messages948935 -Ref: Printing Messages-Footnote-1950012 -Node: Updating `ERRNO'950164 -Node: Accessing Parameters950903 -Node: Symbol Table Access952133 -Node: Symbol table by name952647 -Node: Symbol table by cookie954623 -Ref: Symbol table by cookie-Footnote-1958756 -Node: Cached values958819 -Ref: Cached values-Footnote-1962323 -Node: Array Manipulation962414 -Ref: Array Manipulation-Footnote-1963512 -Node: Array Data Types963551 -Ref: Array Data Types-Footnote-1966254 -Node: Array Functions966346 -Node: Flattening Arrays970220 -Node: Creating Arrays977072 -Node: Extension API Variables981803 -Node: Extension Versioning982439 -Node: Extension API Informational Variables984340 -Node: Extension API Boilerplate985426 -Node: Finding Extensions989230 -Node: Extension Example989790 -Node: Internal File Description990520 -Node: Internal File Ops994611 -Ref: Internal File Ops-Footnote-11006043 -Node: Using Internal File Ops1006183 -Ref: Using Internal File Ops-Footnote-11008530 -Node: Extension Samples1008798 -Node: Extension Sample File Functions1010322 -Node: Extension Sample Fnmatch1017890 -Node: Extension Sample Fork1019372 -Node: Extension Sample Inplace1020585 -Node: Extension Sample Ord1022260 -Node: Extension Sample Readdir1023096 -Ref: table-readdir-file-types1023952 -Node: Extension Sample Revout1024751 -Node: Extension Sample Rev2way1025342 -Node: Extension Sample Read write array1026083 -Node: Extension Sample Readfile1027962 -Node: Extension Sample API Tests1029062 -Node: Extension Sample Time1029587 -Node: gawkextlib1030902 -Node: Extension summary1033715 -Node: Extension Exercises1037408 -Node: Language History1038130 -Node: V7/SVR3.11039773 -Node: SVR41042093 -Node: POSIX1043535 -Node: BTL1044921 -Node: POSIX/GNU1045655 -Node: Feature History1051371 -Node: Common Extensions1064462 -Node: Ranges and Locales1065774 -Ref: Ranges and Locales-Footnote-11070391 -Ref: Ranges and Locales-Footnote-21070418 -Ref: Ranges and Locales-Footnote-31070652 -Node: Contributors1070873 -Node: History summary1076298 -Node: Installation1077667 -Node: Gawk Distribution1078618 -Node: Getting1079102 -Node: Extracting1079926 -Node: Distribution contents1081568 -Node: Unix Installation1087338 -Node: Quick Installation1087955 -Node: Additional Configuration Options1090397 -Node: Configuration Philosophy1092135 -Node: Non-Unix Installation1094486 -Node: PC Installation1094944 -Node: PC Binary Installation1096255 -Node: PC Compiling1098103 -Ref: PC Compiling-Footnote-11101102 -Node: PC Testing1101207 -Node: PC Using1102383 -Node: Cygwin1106535 -Node: MSYS1107344 -Node: VMS Installation1107858 -Node: VMS Compilation1108654 -Ref: VMS Compilation-Footnote-11109876 -Node: VMS Dynamic Extensions1109934 -Node: VMS Installation Details1111307 -Node: VMS Running1113559 -Node: VMS GNV1116393 -Node: VMS Old Gawk1117116 -Node: Bugs1117586 -Node: Other Versions1121590 -Node: Installation summary1127817 -Node: Notes1128873 -Node: Compatibility Mode1129738 -Node: Additions1130520 -Node: Accessing The Source1131445 -Node: Adding Code1132881 -Node: New Ports1139059 -Node: Derived Files1143540 -Ref: Derived Files-Footnote-11148621 -Ref: Derived Files-Footnote-21148655 -Ref: Derived Files-Footnote-31149251 -Node: Future Extensions1149365 -Node: Implementation Limitations1149971 -Node: Extension Design1151219 -Node: Old Extension Problems1152373 -Ref: Old Extension Problems-Footnote-11153890 -Node: Extension New Mechanism Goals1153947 -Ref: Extension New Mechanism Goals-Footnote-11157307 -Node: Extension Other Design Decisions1157496 -Node: Extension Future Growth1159602 -Node: Old Extension Mechanism1160438 -Node: Notes summary1162200 -Node: Basic Concepts1163386 -Node: Basic High Level1164067 -Ref: figure-general-flow1164339 -Ref: figure-process-flow1164938 -Ref: Basic High Level-Footnote-11168167 -Node: Basic Data Typing1168352 -Node: Glossary1171680 -Node: Copying1196832 -Node: GNU Free Documentation License1234388 -Node: Index1259524 +Ref: When-Footnote-1109847 +Node: Intro Summary109912 +Node: Invoking Gawk110795 +Node: Command Line112310 +Node: Options113101 +Ref: Options-Footnote-1128748 +Node: Other Arguments128773 +Node: Naming Standard Input131435 +Node: Environment Variables132528 +Node: AWKPATH Variable133086 +Ref: AWKPATH Variable-Footnote-1135952 +Ref: AWKPATH Variable-Footnote-2135997 +Node: AWKLIBPATH Variable136257 +Node: Other Environment Variables137016 +Node: Exit Status140468 +Node: Include Files141143 +Node: Loading Shared Libraries144721 +Node: Obsolete146105 +Node: Undocumented146802 +Node: Invoking Summary147069 +Node: Regexp148669 +Node: Regexp Usage150128 +Node: Escape Sequences152161 +Node: Regexp Operators158061 +Ref: Regexp Operators-Footnote-1165579 +Ref: Regexp Operators-Footnote-2165726 +Node: Bracket Expressions165824 +Ref: table-char-classes167846 +Node: GNU Regexp Operators170786 +Node: Case-sensitivity174495 +Ref: Case-sensitivity-Footnote-1177387 +Ref: Case-sensitivity-Footnote-2177622 +Node: Leftmost Longest177730 +Node: Computed Regexps178931 +Node: Regexp Summary182303 +Node: Reading Files183772 +Node: Records185864 +Node: awk split records186586 +Node: gawk split records191444 +Ref: gawk split records-Footnote-1195965 +Node: Fields196002 +Ref: Fields-Footnote-1198966 +Node: Nonconstant Fields199052 +Ref: Nonconstant Fields-Footnote-1201282 +Node: Changing Fields201484 +Node: Field Separators207438 +Node: Default Field Splitting210140 +Node: Regexp Field Splitting211257 +Node: Single Character Fields214584 +Node: Command Line Field Separator215643 +Node: Full Line Fields219069 +Ref: Full Line Fields-Footnote-1219577 +Node: Field Splitting Summary219623 +Ref: Field Splitting Summary-Footnote-1222755 +Node: Constant Size222856 +Node: Splitting By Content227462 +Ref: Splitting By Content-Footnote-1231535 +Node: Multiple Line231575 +Ref: Multiple Line-Footnote-1237431 +Node: Getline237610 +Node: Plain Getline239821 +Node: Getline/Variable241916 +Node: Getline/File243063 +Node: Getline/Variable/File244447 +Ref: Getline/Variable/File-Footnote-1246046 +Node: Getline/Pipe246133 +Node: Getline/Variable/Pipe248819 +Node: Getline/Coprocess249926 +Node: Getline/Variable/Coprocess251178 +Node: Getline Notes251915 +Node: Getline Summary254719 +Ref: table-getline-variants255127 +Node: Read Timeout256039 +Ref: Read Timeout-Footnote-1259866 +Node: Command-line directories259924 +Node: Input Summary260828 +Node: Input Exercises263965 +Node: Printing264698 +Node: Print266420 +Node: Print Examples267913 +Node: Output Separators270692 +Node: OFMT272708 +Node: Printf274066 +Node: Basic Printf274972 +Node: Control Letters276511 +Node: Format Modifiers280502 +Node: Printf Examples286529 +Node: Redirection288993 +Node: Special Files295965 +Node: Special FD296498 +Ref: Special FD-Footnote-1300095 +Node: Special Network300169 +Node: Special Caveats301019 +Node: Close Files And Pipes301815 +Ref: Close Files And Pipes-Footnote-1308976 +Ref: Close Files And Pipes-Footnote-2309124 +Node: Output Summary309274 +Node: Output exercises310271 +Node: Expressions310951 +Node: Values312136 +Node: Constants312812 +Node: Scalar Constants313492 +Ref: Scalar Constants-Footnote-1314351 +Node: Nondecimal-numbers314601 +Node: Regexp Constants317601 +Node: Using Constant Regexps318076 +Node: Variables321148 +Node: Using Variables321803 +Node: Assignment Options323527 +Node: Conversion325402 +Node: Strings And Numbers325926 +Ref: Strings And Numbers-Footnote-1328988 +Node: Locale influences conversions329097 +Ref: table-locale-affects331814 +Node: All Operators332402 +Node: Arithmetic Ops333032 +Node: Concatenation335537 +Ref: Concatenation-Footnote-1338356 +Node: Assignment Ops338462 +Ref: table-assign-ops343445 +Node: Increment Ops344748 +Node: Truth Values and Conditions348186 +Node: Truth Values349269 +Node: Typing and Comparison350318 +Node: Variable Typing351111 +Node: Comparison Operators354763 +Ref: table-relational-ops355173 +Node: POSIX String Comparison358723 +Ref: POSIX String Comparison-Footnote-1359807 +Node: Boolean Ops359945 +Ref: Boolean Ops-Footnote-1364020 +Node: Conditional Exp364111 +Node: Function Calls365838 +Node: Precedence369718 +Node: Locales373387 +Node: Expressions Summary375018 +Node: Patterns and Actions377559 +Node: Pattern Overview378675 +Node: Regexp Patterns380352 +Node: Expression Patterns380895 +Node: Ranges384675 +Node: BEGIN/END387781 +Node: Using BEGIN/END388543 +Ref: Using BEGIN/END-Footnote-1391279 +Node: I/O And BEGIN/END391385 +Node: BEGINFILE/ENDFILE393656 +Node: Empty396587 +Node: Using Shell Variables396904 +Node: Action Overview399187 +Node: Statements401514 +Node: If Statement403362 +Node: While Statement404860 +Node: Do Statement406904 +Node: For Statement408060 +Node: Switch Statement411212 +Node: Break Statement413600 +Node: Continue Statement415641 +Node: Next Statement417466 +Node: Nextfile Statement419856 +Node: Exit Statement422492 +Node: Built-in Variables424896 +Node: User-modified426023 +Ref: User-modified-Footnote-1433712 +Node: Auto-set433774 +Ref: Auto-set-Footnote-1446693 +Ref: Auto-set-Footnote-2446898 +Node: ARGC and ARGV446954 +Node: Pattern Action Summary450858 +Node: Arrays453081 +Node: Array Basics454630 +Node: Array Intro455456 +Ref: figure-array-elements457429 +Node: Reference to Elements459836 +Node: Assigning Elements462286 +Node: Array Example462777 +Node: Scanning an Array464509 +Node: Controlling Scanning467510 +Ref: Controlling Scanning-Footnote-1472683 +Node: Delete472999 +Ref: Delete-Footnote-1475750 +Node: Numeric Array Subscripts475807 +Node: Uninitialized Subscripts477990 +Node: Multidimensional479615 +Node: Multiscanning482728 +Node: Arrays of Arrays484317 +Node: Arrays Summary488980 +Node: Functions491085 +Node: Built-in491958 +Node: Calling Built-in493036 +Node: Numeric Functions495024 +Ref: Numeric Functions-Footnote-1499860 +Ref: Numeric Functions-Footnote-2500217 +Ref: Numeric Functions-Footnote-3500265 +Node: String Functions500534 +Ref: String Functions-Footnote-1523531 +Ref: String Functions-Footnote-2523660 +Ref: String Functions-Footnote-3523908 +Node: Gory Details523995 +Ref: table-sub-escapes525768 +Ref: table-sub-proposed527288 +Ref: table-posix-sub528652 +Ref: table-gensub-escapes530192 +Ref: Gory Details-Footnote-1531368 +Node: I/O Functions531519 +Ref: I/O Functions-Footnote-1538629 +Node: Time Functions538776 +Ref: Time Functions-Footnote-1549240 +Ref: Time Functions-Footnote-2549308 +Ref: Time Functions-Footnote-3549466 +Ref: Time Functions-Footnote-4549577 +Ref: Time Functions-Footnote-5549689 +Ref: Time Functions-Footnote-6549916 +Node: Bitwise Functions550182 +Ref: table-bitwise-ops550744 +Ref: Bitwise Functions-Footnote-1554989 +Node: Type Functions555173 +Node: I18N Functions556315 +Node: User-defined557960 +Node: Definition Syntax558764 +Ref: Definition Syntax-Footnote-1563943 +Node: Function Example564012 +Ref: Function Example-Footnote-1566652 +Node: Function Caveats566674 +Node: Calling A Function567192 +Node: Variable Scope568147 +Node: Pass By Value/Reference571135 +Node: Return Statement574645 +Node: Dynamic Typing577629 +Node: Indirect Calls578558 +Node: Functions Summary588271 +Node: Library Functions590810 +Ref: Library Functions-Footnote-1594428 +Ref: Library Functions-Footnote-2594571 +Node: Library Names594742 +Ref: Library Names-Footnote-1598215 +Ref: Library Names-Footnote-2598435 +Node: General Functions598521 +Node: Strtonum Function599549 +Node: Assert Function602329 +Node: Round Function605655 +Node: Cliff Random Function607196 +Node: Ordinal Functions608212 +Ref: Ordinal Functions-Footnote-1611277 +Ref: Ordinal Functions-Footnote-2611529 +Node: Join Function611740 +Ref: Join Function-Footnote-1613511 +Node: Getlocaltime Function613711 +Node: Readfile Function617447 +Node: Data File Management619286 +Node: Filetrans Function619918 +Node: Rewind Function623987 +Node: File Checking625545 +Ref: File Checking-Footnote-1626677 +Node: Empty Files626878 +Node: Ignoring Assigns628857 +Node: Getopt Function630411 +Ref: Getopt Function-Footnote-1641714 +Node: Passwd Functions641917 +Ref: Passwd Functions-Footnote-1650896 +Node: Group Functions650984 +Ref: Group Functions-Footnote-1658915 +Node: Walking Arrays659128 +Node: Library Functions Summary660731 +Node: Library exercises662119 +Node: Sample Programs663399 +Node: Running Examples664169 +Node: Clones664897 +Node: Cut Program666121 +Node: Egrep Program675979 +Ref: Egrep Program-Footnote-1683566 +Node: Id Program683676 +Node: Split Program687330 +Ref: Split Program-Footnote-1690868 +Node: Tee Program690996 +Node: Uniq Program693783 +Node: Wc Program701204 +Ref: Wc Program-Footnote-1705469 +Node: Miscellaneous Programs705561 +Node: Dupword Program706774 +Node: Alarm Program708805 +Node: Translate Program713609 +Ref: Translate Program-Footnote-1718000 +Ref: Translate Program-Footnote-2718270 +Node: Labels Program718404 +Ref: Labels Program-Footnote-1721765 +Node: Word Sorting721849 +Node: History Sorting725892 +Node: Extract Program727728 +Node: Simple Sed735264 +Node: Igawk Program738326 +Ref: Igawk Program-Footnote-1752630 +Ref: Igawk Program-Footnote-2752831 +Node: Anagram Program752969 +Node: Signature Program756037 +Node: Programs Summary757284 +Node: Programs Exercises758499 +Node: Advanced Features762150 +Node: Nondecimal Data764098 +Node: Array Sorting765675 +Node: Controlling Array Traversal766372 +Node: Array Sorting Functions774652 +Ref: Array Sorting Functions-Footnote-1778559 +Node: Two-way I/O778753 +Ref: Two-way I/O-Footnote-1783697 +Ref: Two-way I/O-Footnote-2783876 +Node: TCP/IP Networking783958 +Node: Profiling786803 +Node: Advanced Features Summary794354 +Node: Internationalization796218 +Node: I18N and L10N797698 +Node: Explaining gettext798384 +Ref: Explaining gettext-Footnote-1803410 +Ref: Explaining gettext-Footnote-2803594 +Node: Programmer i18n803759 +Ref: Programmer i18n-Footnote-1808553 +Node: Translator i18n808602 +Node: String Extraction809396 +Ref: String Extraction-Footnote-1810529 +Node: Printf Ordering810615 +Ref: Printf Ordering-Footnote-1813397 +Node: I18N Portability813461 +Ref: I18N Portability-Footnote-1815910 +Node: I18N Example815973 +Ref: I18N Example-Footnote-1818679 +Node: Gawk I18N818751 +Node: I18N Summary819389 +Node: Debugger820728 +Node: Debugging821750 +Node: Debugging Concepts822191 +Node: Debugging Terms824047 +Node: Awk Debugging826644 +Node: Sample Debugging Session827536 +Node: Debugger Invocation828056 +Node: Finding The Bug829389 +Node: List of Debugger Commands835871 +Node: Breakpoint Control837203 +Node: Debugger Execution Control840867 +Node: Viewing And Changing Data844227 +Node: Execution Stack847585 +Node: Debugger Info849098 +Node: Miscellaneous Debugger Commands853092 +Node: Readline Support858276 +Node: Limitations859168 +Node: Debugging Summary861442 +Node: Arbitrary Precision Arithmetic862610 +Node: Computer Arithmetic864097 +Ref: Computer Arithmetic-Footnote-1868484 +Node: Math Definitions868541 +Ref: table-ieee-formats871830 +Ref: Math Definitions-Footnote-1872370 +Node: MPFR features872473 +Node: FP Math Caution874090 +Ref: FP Math Caution-Footnote-1875140 +Node: Inexactness of computations875509 +Node: Inexact representation876457 +Node: Comparing FP Values877812 +Node: Errors accumulate878776 +Node: Getting Accuracy880209 +Node: Try To Round882868 +Node: Setting precision883767 +Ref: table-predefined-precision-strings884449 +Node: Setting the rounding mode886242 +Ref: table-gawk-rounding-modes886606 +Ref: Setting the rounding mode-Footnote-1890060 +Node: Arbitrary Precision Integers890239 +Ref: Arbitrary Precision Integers-Footnote-1894012 +Node: POSIX Floating Point Problems894161 +Ref: POSIX Floating Point Problems-Footnote-1898037 +Node: Floating point summary898075 +Node: Dynamic Extensions900279 +Node: Extension Intro901831 +Node: Plugin License903096 +Node: Extension Mechanism Outline903781 +Ref: figure-load-extension904205 +Ref: figure-load-new-function905690 +Ref: figure-call-new-function906692 +Node: Extension API Description908676 +Node: Extension API Functions Introduction910126 +Node: General Data Types914993 +Ref: General Data Types-Footnote-1920686 +Node: Requesting Values920985 +Ref: table-value-types-returned921722 +Node: Memory Allocation Functions922680 +Ref: Memory Allocation Functions-Footnote-1925427 +Node: Constructor Functions925523 +Node: Registration Functions927281 +Node: Extension Functions927966 +Node: Exit Callback Functions930268 +Node: Extension Version String931516 +Node: Input Parsers932166 +Node: Output Wrappers941980 +Node: Two-way processors946496 +Node: Printing Messages948700 +Ref: Printing Messages-Footnote-1949777 +Node: Updating `ERRNO'949929 +Node: Accessing Parameters950668 +Node: Symbol Table Access951898 +Node: Symbol table by name952412 +Node: Symbol table by cookie954388 +Ref: Symbol table by cookie-Footnote-1958521 +Node: Cached values958584 +Ref: Cached values-Footnote-1962088 +Node: Array Manipulation962179 +Ref: Array Manipulation-Footnote-1963277 +Node: Array Data Types963316 +Ref: Array Data Types-Footnote-1966019 +Node: Array Functions966111 +Node: Flattening Arrays969985 +Node: Creating Arrays976837 +Node: Extension API Variables981568 +Node: Extension Versioning982204 +Node: Extension API Informational Variables984105 +Node: Extension API Boilerplate985191 +Node: Finding Extensions988995 +Node: Extension Example989555 +Node: Internal File Description990285 +Node: Internal File Ops994376 +Ref: Internal File Ops-Footnote-11005808 +Node: Using Internal File Ops1005948 +Ref: Using Internal File Ops-Footnote-11008295 +Node: Extension Samples1008563 +Node: Extension Sample File Functions1010087 +Node: Extension Sample Fnmatch1017655 +Node: Extension Sample Fork1019137 +Node: Extension Sample Inplace1020350 +Node: Extension Sample Ord1022025 +Node: Extension Sample Readdir1022861 +Ref: table-readdir-file-types1023717 +Node: Extension Sample Revout1024516 +Node: Extension Sample Rev2way1025107 +Node: Extension Sample Read write array1025848 +Node: Extension Sample Readfile1027727 +Node: Extension Sample API Tests1028827 +Node: Extension Sample Time1029352 +Node: gawkextlib1030667 +Node: Extension summary1033480 +Node: Extension Exercises1037173 +Node: Language History1037895 +Node: V7/SVR3.11039538 +Node: SVR41041858 +Node: POSIX1043300 +Node: BTL1044686 +Node: POSIX/GNU1045420 +Node: Feature History1051136 +Node: Common Extensions1064227 +Node: Ranges and Locales1065539 +Ref: Ranges and Locales-Footnote-11070156 +Ref: Ranges and Locales-Footnote-21070183 +Ref: Ranges and Locales-Footnote-31070417 +Node: Contributors1070638 +Node: History summary1076063 +Node: Installation1077432 +Node: Gawk Distribution1078383 +Node: Getting1078867 +Node: Extracting1079691 +Node: Distribution contents1081333 +Node: Unix Installation1087103 +Node: Quick Installation1087720 +Node: Additional Configuration Options1090162 +Node: Configuration Philosophy1091900 +Node: Non-Unix Installation1094251 +Node: PC Installation1094709 +Node: PC Binary Installation1096020 +Node: PC Compiling1097868 +Ref: PC Compiling-Footnote-11100867 +Node: PC Testing1100972 +Node: PC Using1102148 +Node: Cygwin1106300 +Node: MSYS1107109 +Node: VMS Installation1107623 +Node: VMS Compilation1108419 +Ref: VMS Compilation-Footnote-11109641 +Node: VMS Dynamic Extensions1109699 +Node: VMS Installation Details1111072 +Node: VMS Running1113324 +Node: VMS GNV1116158 +Node: VMS Old Gawk1116881 +Node: Bugs1117351 +Node: Other Versions1121355 +Node: Installation summary1127582 +Node: Notes1128638 +Node: Compatibility Mode1129503 +Node: Additions1130285 +Node: Accessing The Source1131210 +Node: Adding Code1132646 +Node: New Ports1138824 +Node: Derived Files1143305 +Ref: Derived Files-Footnote-11148386 +Ref: Derived Files-Footnote-21148420 +Ref: Derived Files-Footnote-31149016 +Node: Future Extensions1149130 +Node: Implementation Limitations1149736 +Node: Extension Design1150984 +Node: Old Extension Problems1152138 +Ref: Old Extension Problems-Footnote-11153655 +Node: Extension New Mechanism Goals1153712 +Ref: Extension New Mechanism Goals-Footnote-11157072 +Node: Extension Other Design Decisions1157261 +Node: Extension Future Growth1159367 +Node: Old Extension Mechanism1160203 +Node: Notes summary1161965 +Node: Basic Concepts1163151 +Node: Basic High Level1163832 +Ref: figure-general-flow1164104 +Ref: figure-process-flow1164703 +Ref: Basic High Level-Footnote-11167932 +Node: Basic Data Typing1168117 +Node: Glossary1171445 +Node: Copying1196597 +Node: GNU Free Documentation License1234153 +Node: Index1259289 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 52c526a4..5f3d9e8e 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -3415,9 +3415,7 @@ eight-bit microprocessors, and a microcode assembler for a special-purpose Prolog computer. While the original @command{awk}'s capabilities were strained by tasks -of such complexity, modern versions are more capable. Even BWK @command{awk} -has fewer predefined limits, and those -that it has are much larger than they used to be. +of such complexity, modern versions are more capable. @cindex @command{awk} programs, complex If you find yourself writing @command{awk} scripts of more than, say, @@ -3431,11 +3429,16 @@ and Perl.} @node Intro Summary @section Summary +@c FIXME: Review this chapter for summary of builtin functions called. @itemize @value{BULLET} @item Programs in @command{awk} consist of @var{pattern}-@var{action} pairs. @item +An @var{action} without a @var{pattern} always runs. The default +@var{action} for a pattern without one is @samp{@{ print $0 @}}. + +@item Use either @samp{awk '@var{program}' @var{files}} or @@ -4724,7 +4727,7 @@ The simplest regular expression is a sequence of letters, numbers, or both. Such a regexp matches any string that contains that sequence. Thus, the regexp @samp{foo} matches any string containing @samp{foo}. Therefore, the pattern @code{/foo/} matches any input record containing -the three characters @samp{foo} @emph{anywhere} in the record. Other +the three adjacent characters @samp{foo} @emph{anywhere} in the record. Other kinds of regexps let you specify more complicated classes of strings. @ifnotinfo @@ -5251,12 +5254,11 @@ or @samp{k}. @cindex vertical bar (@code{|}) @item @code{|} This is the @dfn{alternation operator} and it is used to specify -alternatives. -The @samp{|} has the lowest precedence of all the regular -expression operators. -For example, @samp{^P|[[:digit:]]} -matches any string that matches either @samp{^P} or @samp{[[:digit:]]}. This -means it matches any string that starts with @samp{P} or contains a digit. +alternatives. The @samp{|} has the lowest precedence of all the regular +expression operators. For example, @samp{^P|[aeiouy]} matches any string +that matches either @samp{^P} or @samp{[aeiouy]}. This means it matches +any string that starts with @samp{P} or contains (anywhere within it) +a lowercase English vowel. The alternation applies to the largest possible regexps on either side. @@ -5415,6 +5417,9 @@ bracket expression, put a @samp{\} in front of it. For example: @noindent matches either @samp{d} or @samp{]}. +Additionally, if you place @samp{]} right after the opening +@samp{[}, the closing bracket is treated as one of the +characters to be matched. @cindex POSIX @command{awk}, bracket expressions and @cindex Extended Regular Expressions (EREs) @@ -6039,7 +6044,7 @@ the match, such as for text substitution and when the record separator is a regexp. @item -Matching expressions may use dynamic regexps; that is, string values +Matching expressions may use dynamic regexps, that is, string values treated as regular expressions. @end itemize @@ -6106,16 +6111,13 @@ used with it do not have to be named on the @command{awk} command line @cindex records, splitting input into @cindex @code{NR} variable @cindex @code{FNR} variable -The @command{awk} utility divides the input for your @command{awk} -program into records and fields. -@command{awk} keeps track of the number of records that have -been read -so far -from the current input file. This value is stored in a -built-in variable called @code{FNR}. It is reset to zero when a new -file is started. Another built-in variable, @code{NR}, records the total -number of input records read so far from all @value{DF}s. It starts at zero, -but is never automatically reset to zero. +@command{awk} divides the input for your program into records and fields. +It keeps track of the number of records that have been read so far from +the current input file. This value is stored in a built-in variable +called @code{FNR} which is reset to zero when a new file is started. +Another built-in variable, @code{NR}, records the total number of input +records read so far from all @value{DF}s. It starts at zero, but is +never automatically reset to zero. @menu * awk split records:: How standard @command{awk} splits records. @@ -7904,7 +7906,7 @@ and have a good knowledge of how @command{awk} works. @cindex @code{getline} command, return values @cindex @option{--sandbox} option, input redirection with @code{getline} -The @code{getline} command returns one if it finds a record and zero if +The @code{getline} command returns 1 if it finds a record and 0 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 @code{getline} returns @minus{}1. In this case, @command{gawk} sets the variable @@ -12258,7 +12260,7 @@ is ``short-circuited'' if the result can be determined part way through its evaluation. @cindex line continuations -Statements that use @samp{&&} or @samp{||} can be continued simply +Statements that end with @samp{&&} or @samp{||} can be continued simply by putting a newline after them. But you cannot put a newline in front of either of these operators without using backslash continuation (@pxref{Statements/Lines}). @@ -12917,7 +12919,7 @@ Contrast this with the following regular expression match, which accepts any record with a first field that contains @samp{li}: @example -$ @kbd{awk '$1 ~ /foo/ @{ print $2 @}' mail-list} +$ @kbd{awk '$1 ~ /li/ @{ print $2 @}' mail-list} @print{} 555-5553 @print{} 555-6699 @end example @@ -15553,6 +15555,8 @@ This expression tests whether the particular index @var{indx} exists, without the side effect of creating that element if it is not present. The expression has the value one (true) if @code{@var{array}[@var{indx}]} exists and zero (false) if it does not exist. +(We use @var{indx} here, since @samp{index} is the name of a built-in +function.) For example, this statement tests whether the array @code{frequencies} contains the index @samp{2}: @@ -20832,8 +20836,7 @@ function chr(c) @c endfile #### test code #### -# BEGIN \ -# @{ +# BEGIN @{ # for (;;) @{ # printf("enter a character: ") # if (getline var <= 0) @@ -22390,8 +22393,7 @@ There are several, modeled after the C library functions of the same names: @c line break on _gr_init for smallbook @c file eg/lib/groupawk.in -BEGIN \ -@{ +BEGIN @{ # Change to suit your system _gr_awklib = "/usr/local/libexec/awk/" @} @@ -22968,8 +22970,7 @@ string: @example @c file eg/prog/cut.awk -BEGIN \ -@{ +BEGIN @{ FS = "\t" # default OFS = FS while ((c = getopt(ARGC, ARGV, "sf:c:d:")) != -1) @{ @@ -23444,8 +23445,7 @@ there are no matches, the exit status is one; otherwise it is zero: @example @c file eg/prog/egrep.awk -END \ -@{ +END @{ exit (total == 0) @} @c endfile @@ -23469,17 +23469,6 @@ function usage( e) The variable @code{e} is used so that the function fits nicely on the printed page. -@cindex @code{END} pattern, backslash continuation and -@cindex @code{\} (backslash), continuing lines and -@cindex backslash (@code{\}), continuing lines and -Just a note on programming style: you may have noticed that the @code{END} -rule uses backslash continuation, with the open brace on a line by -itself. This is so that it more closely resembles the way functions -are written. Many of the examples -in this @value{CHAPTER} -use this style. You can decide for yourself if you like writing -your @code{BEGIN} and @code{END} rules this way -or not. @c ENDOFRANGE regexps @c ENDOFRANGE sfregexp @c ENDOFRANGE fsregexp @@ -23546,8 +23535,7 @@ numbers: # egid=5(blat) groups=9(nine),2(two),1(one) @group -BEGIN \ -@{ +BEGIN @{ uid = PROCINFO["uid"] euid = PROCINFO["euid"] gid = PROCINFO["gid"] @@ -23817,8 +23805,7 @@ Finally, @command{awk} is forced to read the standard input by setting @c endfile @end ignore @c file eg/prog/tee.awk -BEGIN \ -@{ +BEGIN @{ for (i = 1; i < ARGC; i++) copy[i] = ARGV[i] @@ -23880,8 +23867,7 @@ Finally, the @code{END} rule cleans up by closing all the output files: @example @c file eg/prog/tee.awk -END \ -@{ +END @{ for (i in copy) close(copy[i]) @} @@ -23998,8 +23984,7 @@ function usage( e) # -n skip n fields # +n skip n characters, skip fields first -BEGIN \ -@{ +BEGIN @{ count = 1 outputfile = "/dev/stdout" opts = "udc0:1:2:3:4:5:6:7:8:9:" @@ -24518,8 +24503,7 @@ Here is the program: @c file eg/prog/alarm.awk # usage: alarm time [ "message" [ count [ delay ] ] ] -BEGIN \ -@{ +BEGIN @{ # Initial argument sanity checking usage1 = "usage: alarm time ['message' [count [delay]]]" usage2 = sprintf("\t(%s) time ::= hh:mm", ARGV[1]) @@ -24914,8 +24898,7 @@ function printpage( i, j) Count++ @} -END \ -@{ +END @{ printpage() @} @c endfile diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 0ba31813..4b3dafb9 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -3343,9 +3343,7 @@ eight-bit microprocessors, and a microcode assembler for a special-purpose Prolog computer. While the original @command{awk}'s capabilities were strained by tasks -of such complexity, modern versions are more capable. Even BWK @command{awk} -has fewer predefined limits, and those -that it has are much larger than they used to be. +of such complexity, modern versions are more capable. @cindex @command{awk} programs, complex If you find yourself writing @command{awk} scripts of more than, say, @@ -3359,11 +3357,16 @@ and Perl.} @node Intro Summary @section Summary +@c FIXME: Review this chapter for summary of builtin functions called. @itemize @value{BULLET} @item Programs in @command{awk} consist of @var{pattern}-@var{action} pairs. @item +An @var{action} without a @var{pattern} always runs. The default +@var{action} for a pattern without one is @samp{@{ print $0 @}}. + +@item Use either @samp{awk '@var{program}' @var{files}} or @@ -4652,7 +4655,7 @@ The simplest regular expression is a sequence of letters, numbers, or both. Such a regexp matches any string that contains that sequence. Thus, the regexp @samp{foo} matches any string containing @samp{foo}. Therefore, the pattern @code{/foo/} matches any input record containing -the three characters @samp{foo} @emph{anywhere} in the record. Other +the three adjacent characters @samp{foo} @emph{anywhere} in the record. Other kinds of regexps let you specify more complicated classes of strings. @ifnotinfo @@ -5096,12 +5099,11 @@ or @samp{k}. @cindex vertical bar (@code{|}) @item @code{|} This is the @dfn{alternation operator} and it is used to specify -alternatives. -The @samp{|} has the lowest precedence of all the regular -expression operators. -For example, @samp{^P|[[:digit:]]} -matches any string that matches either @samp{^P} or @samp{[[:digit:]]}. This -means it matches any string that starts with @samp{P} or contains a digit. +alternatives. The @samp{|} has the lowest precedence of all the regular +expression operators. For example, @samp{^P|[aeiouy]} matches any string +that matches either @samp{^P} or @samp{[aeiouy]}. This means it matches +any string that starts with @samp{P} or contains (anywhere within it) +a lowercase English vowel. The alternation applies to the largest possible regexps on either side. @@ -5260,6 +5262,9 @@ bracket expression, put a @samp{\} in front of it. For example: @noindent matches either @samp{d} or @samp{]}. +Additionally, if you place @samp{]} right after the opening +@samp{[}, the closing bracket is treated as one of the +characters to be matched. @cindex POSIX @command{awk}, bracket expressions and @cindex Extended Regular Expressions (EREs) @@ -5840,7 +5845,7 @@ the match, such as for text substitution and when the record separator is a regexp. @item -Matching expressions may use dynamic regexps; that is, string values +Matching expressions may use dynamic regexps, that is, string values treated as regular expressions. @end itemize @@ -5907,16 +5912,13 @@ used with it do not have to be named on the @command{awk} command line @cindex records, splitting input into @cindex @code{NR} variable @cindex @code{FNR} variable -The @command{awk} utility divides the input for your @command{awk} -program into records and fields. -@command{awk} keeps track of the number of records that have -been read -so far -from the current input file. This value is stored in a -built-in variable called @code{FNR}. It is reset to zero when a new -file is started. Another built-in variable, @code{NR}, records the total -number of input records read so far from all @value{DF}s. It starts at zero, -but is never automatically reset to zero. +@command{awk} divides the input for your program into records and fields. +It keeps track of the number of records that have been read so far from +the current input file. This value is stored in a built-in variable +called @code{FNR} which is reset to zero when a new file is started. +Another built-in variable, @code{NR}, records the total number of input +records read so far from all @value{DF}s. It starts at zero, but is +never automatically reset to zero. @menu * awk split records:: How standard @command{awk} splits records. @@ -7523,7 +7525,7 @@ and have a good knowledge of how @command{awk} works. @cindex @code{getline} command, return values @cindex @option{--sandbox} option, input redirection with @code{getline} -The @code{getline} command returns one if it finds a record and zero if +The @code{getline} command returns 1 if it finds a record and 0 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 @code{getline} returns @minus{}1. In this case, @command{gawk} sets the variable @@ -11609,7 +11611,7 @@ is ``short-circuited'' if the result can be determined part way through its evaluation. @cindex line continuations -Statements that use @samp{&&} or @samp{||} can be continued simply +Statements that end with @samp{&&} or @samp{||} can be continued simply by putting a newline after them. But you cannot put a newline in front of either of these operators without using backslash continuation (@pxref{Statements/Lines}). @@ -12268,7 +12270,7 @@ Contrast this with the following regular expression match, which accepts any record with a first field that contains @samp{li}: @example -$ @kbd{awk '$1 ~ /foo/ @{ print $2 @}' mail-list} +$ @kbd{awk '$1 ~ /li/ @{ print $2 @}' mail-list} @print{} 555-5553 @print{} 555-6699 @end example @@ -14858,6 +14860,8 @@ This expression tests whether the particular index @var{indx} exists, without the side effect of creating that element if it is not present. The expression has the value one (true) if @code{@var{array}[@var{indx}]} exists and zero (false) if it does not exist. +(We use @var{indx} here, since @samp{index} is the name of a built-in +function.) For example, this statement tests whether the array @code{frequencies} contains the index @samp{2}: @@ -19976,8 +19980,7 @@ function chr(c) @c endfile #### test code #### -# BEGIN \ -# @{ +# BEGIN @{ # for (;;) @{ # printf("enter a character: ") # if (getline var <= 0) @@ -21505,8 +21508,7 @@ There are several, modeled after the C library functions of the same names: @c line break on _gr_init for smallbook @c file eg/lib/groupawk.in -BEGIN \ -@{ +BEGIN @{ # Change to suit your system _gr_awklib = "/usr/local/libexec/awk/" @} @@ -22083,8 +22085,7 @@ string: @example @c file eg/prog/cut.awk -BEGIN \ -@{ +BEGIN @{ FS = "\t" # default OFS = FS while ((c = getopt(ARGC, ARGV, "sf:c:d:")) != -1) @{ @@ -22559,8 +22560,7 @@ there are no matches, the exit status is one; otherwise it is zero: @example @c file eg/prog/egrep.awk -END \ -@{ +END @{ exit (total == 0) @} @c endfile @@ -22584,17 +22584,6 @@ function usage( e) The variable @code{e} is used so that the function fits nicely on the printed page. -@cindex @code{END} pattern, backslash continuation and -@cindex @code{\} (backslash), continuing lines and -@cindex backslash (@code{\}), continuing lines and -Just a note on programming style: you may have noticed that the @code{END} -rule uses backslash continuation, with the open brace on a line by -itself. This is so that it more closely resembles the way functions -are written. Many of the examples -in this @value{CHAPTER} -use this style. You can decide for yourself if you like writing -your @code{BEGIN} and @code{END} rules this way -or not. @c ENDOFRANGE regexps @c ENDOFRANGE sfregexp @c ENDOFRANGE fsregexp @@ -22661,8 +22650,7 @@ numbers: # egid=5(blat) groups=9(nine),2(two),1(one) @group -BEGIN \ -@{ +BEGIN @{ uid = PROCINFO["uid"] euid = PROCINFO["euid"] gid = PROCINFO["gid"] @@ -22932,8 +22920,7 @@ Finally, @command{awk} is forced to read the standard input by setting @c endfile @end ignore @c file eg/prog/tee.awk -BEGIN \ -@{ +BEGIN @{ for (i = 1; i < ARGC; i++) copy[i] = ARGV[i] @@ -22995,8 +22982,7 @@ Finally, the @code{END} rule cleans up by closing all the output files: @example @c file eg/prog/tee.awk -END \ -@{ +END @{ for (i in copy) close(copy[i]) @} @@ -23113,8 +23099,7 @@ function usage( e) # -n skip n fields # +n skip n characters, skip fields first -BEGIN \ -@{ +BEGIN @{ count = 1 outputfile = "/dev/stdout" opts = "udc0:1:2:3:4:5:6:7:8:9:" @@ -23633,8 +23618,7 @@ Here is the program: @c file eg/prog/alarm.awk # usage: alarm time [ "message" [ count [ delay ] ] ] -BEGIN \ -@{ +BEGIN @{ # Initial argument sanity checking usage1 = "usage: alarm time ['message' [count [delay]]]" usage2 = sprintf("\t(%s) time ::= hh:mm", ARGV[1]) @@ -24029,8 +24013,7 @@ function printpage( i, j) Count++ @} -END \ -@{ +END @{ printpage() @} @c endfile |