diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-08-23 22:40:59 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-08-23 22:40:59 +0300 |
commit | 3defec04e39c4ca6987a21f79686576d9823c653 (patch) | |
tree | 29ec09d35813a3677424e35ae465fee903a05c21 | |
parent | f215e2b823693103796cd71493b90300f54adba4 (diff) | |
download | egawk-3defec04e39c4ca6987a21f79686576d9823c653.tar.gz egawk-3defec04e39c4ca6987a21f79686576d9823c653.tar.bz2 egawk-3defec04e39c4ca6987a21f79686576d9823c653.zip |
More reviewer comments.
-rw-r--r-- | awklib/eg/lib/groupawk.in | 3 | ||||
-rw-r--r-- | awklib/eg/prog/alarm.awk | 3 | ||||
-rw-r--r-- | awklib/eg/prog/cut.awk | 3 | ||||
-rw-r--r-- | awklib/eg/prog/egrep.awk | 3 | ||||
-rw-r--r-- | awklib/eg/prog/id.awk | 3 | ||||
-rw-r--r-- | awklib/eg/prog/labels.awk | 3 | ||||
-rw-r--r-- | awklib/eg/prog/tee.awk | 6 | ||||
-rw-r--r-- | awklib/eg/prog/uniq.awk | 3 | ||||
-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 |
12 files changed, 678 insertions, 732 deletions
diff --git a/awklib/eg/lib/groupawk.in b/awklib/eg/lib/groupawk.in index 0917b923..9382bce8 100644 --- a/awklib/eg/lib/groupawk.in +++ b/awklib/eg/lib/groupawk.in @@ -5,8 +5,7 @@ # Revised October 2000 # Revised December 2010 -BEGIN \ -{ +BEGIN { # Change to suit your system _gr_awklib = "/usr/local/libexec/awk/" } diff --git a/awklib/eg/prog/alarm.awk b/awklib/eg/prog/alarm.awk index 63cf64a4..59630ea8 100644 --- a/awklib/eg/prog/alarm.awk +++ b/awklib/eg/prog/alarm.awk @@ -8,8 +8,7 @@ # 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]) diff --git a/awklib/eg/prog/cut.awk b/awklib/eg/prog/cut.awk index 04d9bc11..56e35e71 100644 --- a/awklib/eg/prog/cut.awk +++ b/awklib/eg/prog/cut.awk @@ -20,8 +20,7 @@ function usage( e1, e2) print e2 > "/dev/stderr" exit 1 } -BEGIN \ -{ +BEGIN { FS = "\t" # default OFS = FS while ((c = getopt(ARGC, ARGV, "sf:c:d:")) != -1) { diff --git a/awklib/eg/prog/egrep.awk b/awklib/eg/prog/egrep.awk index 86b3cfda..094bdea5 100644 --- a/awklib/eg/prog/egrep.awk +++ b/awklib/eg/prog/egrep.awk @@ -88,8 +88,7 @@ function endfile(file) print } } -END \ -{ +END { exit (total == 0) } function usage( e) diff --git a/awklib/eg/prog/id.awk b/awklib/eg/prog/id.awk index cf744447..992fa57c 100644 --- a/awklib/eg/prog/id.awk +++ b/awklib/eg/prog/id.awk @@ -11,8 +11,7 @@ # 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"] diff --git a/awklib/eg/prog/labels.awk b/awklib/eg/prog/labels.awk index abf53c3b..3195809b 100644 --- a/awklib/eg/prog/labels.awk +++ b/awklib/eg/prog/labels.awk @@ -48,7 +48,6 @@ function printpage( i, j) Count++ } -END \ -{ +END { printpage() } diff --git a/awklib/eg/prog/tee.awk b/awklib/eg/prog/tee.awk index 639b9f80..fd9985f1 100644 --- a/awklib/eg/prog/tee.awk +++ b/awklib/eg/prog/tee.awk @@ -7,8 +7,7 @@ # May 1993 # Revised December 1995 -BEGIN \ -{ +BEGIN { for (i = 1; i < ARGC; i++) copy[i] = ARGV[i] @@ -35,8 +34,7 @@ BEGIN \ print > copy[i] print } -END \ -{ +END { for (i in copy) close(copy[i]) } diff --git a/awklib/eg/prog/uniq.awk b/awklib/eg/prog/uniq.awk index 990387ac..effc8f6c 100644 --- a/awklib/eg/prog/uniq.awk +++ b/awklib/eg/prog/uniq.awk @@ -18,8 +18,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:" diff --git a/doc/ChangeLog b/doc/ChangeLog index a7cd7d6c..f161e953 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 39da4897..9e4f3ec7 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'. @@ -3207,7 +3208,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. @@ -3502,9 +3503,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. @@ -3630,7 +3632,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 @@ -4025,7 +4029,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. @@ -4078,13 +4082,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: @@ -5339,8 +5343,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. @@ -8441,9 +8445,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 @@ -8919,7 +8923,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 @@ -10802,7 +10806,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) @@ -14651,8 +14656,7 @@ worrying about: } #### test code #### - # BEGIN \ - # { + # BEGIN { # for (;;) { # printf("enter a character: ") # if (getline var <= 0) @@ -15775,8 +15779,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/" } @@ -16199,8 +16202,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) { @@ -16585,8 +16587,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) } @@ -16604,13 +16605,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 @@ -16653,8 +16647,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"] @@ -16862,8 +16855,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] @@ -16913,8 +16905,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]) } @@ -17001,8 +16992,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:" @@ -17390,8 +17380,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]) @@ -17712,8 +17701,7 @@ not have been an even multiple of 20 labels in the data: Count++ } - END \ - { + END { printpage() } @@ -30962,11 +30950,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) @@ -30980,7 +30968,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) @@ -31123,7 +31111,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) @@ -31160,7 +31148,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) @@ -31326,7 +31313,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) @@ -31344,7 +31331,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) @@ -31433,7 +31420,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) @@ -31509,15 +31495,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) @@ -31634,8 +31620,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) @@ -32058,7 +32044,7 @@ Index * effective group ID of gawk user: Auto-set. (line 133) * effective user ID of gawk user: Auto-set. (line 137) * 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) @@ -32084,7 +32070,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. @@ -32096,8 +32081,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) @@ -32110,7 +32095,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 74) * ERRNO variable, with BEGINFILE pattern: BEGINFILE/ENDFILE. (line 26) @@ -32165,7 +32150,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. @@ -32231,7 +32216,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) @@ -32428,7 +32413,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) @@ -32479,7 +32464,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) @@ -32497,7 +32482,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 257) * gawk, RT variable in <2>: Multiple Line. (line 129) * gawk, RT variable in: awk split records. (line 124) @@ -32525,12 +32510,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) @@ -32704,7 +32689,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. @@ -32716,7 +32701,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) @@ -33074,7 +33059,7 @@ Index * Papadopoulos, Panos: Contributors. (line 128) * parent process ID of gawk process: Auto-set. (line 181) * 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. @@ -33112,7 +33097,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 98) * portability, #! (executable scripts): Executable Scripts. (line 33) @@ -33162,9 +33147,9 @@ Index * POSIX awk, backslashes in string constants: Escape Sequences. (line 116) * 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) @@ -33178,14 +33163,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 254) @@ -33196,7 +33181,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) @@ -33283,7 +33268,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) @@ -33383,7 +33368,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) @@ -33593,7 +33578,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) @@ -34013,516 +33998,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-1128865 -Node: Other Arguments128890 -Node: Naming Standard Input131552 -Node: Environment Variables132645 -Node: AWKPATH Variable133203 -Ref: AWKPATH Variable-Footnote-1136069 -Ref: AWKPATH Variable-Footnote-2136114 -Node: AWKLIBPATH Variable136374 -Node: Other Environment Variables137133 -Node: Exit Status140790 -Node: Include Files141465 -Node: Loading Shared Libraries145043 -Node: Obsolete146427 -Node: Undocumented147124 -Node: Invoking Summary147391 -Node: Regexp148991 -Node: Regexp Usage150441 -Node: Escape Sequences152474 -Node: Regexp Operators158291 -Ref: Regexp Operators-Footnote-1165771 -Ref: Regexp Operators-Footnote-2165918 -Node: Bracket Expressions166016 -Ref: table-char-classes167906 -Node: GNU Regexp Operators170846 -Node: Case-sensitivity174555 -Ref: Case-sensitivity-Footnote-1177447 -Ref: Case-sensitivity-Footnote-2177682 -Node: Leftmost Longest177790 -Node: Computed Regexps178991 -Node: Regexp Summary182363 -Node: Reading Files183832 -Node: Records185924 -Node: awk split records186667 -Node: gawk split records191525 -Ref: gawk split records-Footnote-1196046 -Node: Fields196083 -Ref: Fields-Footnote-1199047 -Node: Nonconstant Fields199133 -Ref: Nonconstant Fields-Footnote-1201363 -Node: Changing Fields201565 -Node: Field Separators207519 -Node: Default Field Splitting210221 -Node: Regexp Field Splitting211338 -Node: Single Character Fields214665 -Node: Command Line Field Separator215724 -Node: Full Line Fields219150 -Ref: Full Line Fields-Footnote-1219658 -Node: Field Splitting Summary219704 -Ref: Field Splitting Summary-Footnote-1222836 -Node: Constant Size222937 -Node: Splitting By Content227543 -Ref: Splitting By Content-Footnote-1231616 -Node: Multiple Line231656 -Ref: Multiple Line-Footnote-1237512 -Node: Getline237691 -Node: Plain Getline239907 -Node: Getline/Variable242002 -Node: Getline/File243149 -Node: Getline/Variable/File244533 -Ref: Getline/Variable/File-Footnote-1246132 -Node: Getline/Pipe246219 -Node: Getline/Variable/Pipe248905 -Node: Getline/Coprocess250012 -Node: Getline/Variable/Coprocess251264 -Node: Getline Notes252001 -Node: Getline Summary254805 -Ref: table-getline-variants255213 -Node: Read Timeout256125 -Ref: Read Timeout-Footnote-1259952 -Node: Command-line directories260010 -Node: Input Summary260914 -Node: Input Exercises264051 -Node: Printing264784 -Node: Print266506 -Node: Print Examples267999 -Node: Output Separators270778 -Node: OFMT272794 -Node: Printf274152 -Node: Basic Printf275058 -Node: Control Letters276597 -Node: Format Modifiers280588 -Node: Printf Examples286615 -Node: Redirection289079 -Node: Special Files296051 -Node: Special FD296584 -Ref: Special FD-Footnote-1300181 -Node: Special Network300255 -Node: Special Caveats301105 -Node: Close Files And Pipes301901 -Ref: Close Files And Pipes-Footnote-1309062 -Ref: Close Files And Pipes-Footnote-2309210 -Node: Output Summary309360 -Node: Output exercises310357 -Node: Expressions311037 -Node: Values312222 -Node: Constants312898 -Node: Scalar Constants313578 -Ref: Scalar Constants-Footnote-1314437 -Node: Nondecimal-numbers314687 -Node: Regexp Constants317687 -Node: Using Constant Regexps318162 -Node: Variables321234 -Node: Using Variables321889 -Node: Assignment Options323613 -Node: Conversion325488 -Node: Strings And Numbers326012 -Ref: Strings And Numbers-Footnote-1329074 -Node: Locale influences conversions329183 -Ref: table-locale-affects331900 -Node: All Operators332488 -Node: Arithmetic Ops333118 -Node: Concatenation335623 -Ref: Concatenation-Footnote-1338442 -Node: Assignment Ops338548 -Ref: table-assign-ops343531 -Node: Increment Ops344834 -Node: Truth Values and Conditions348272 -Node: Truth Values349355 -Node: Typing and Comparison350404 -Node: Variable Typing351197 -Node: Comparison Operators354849 -Ref: table-relational-ops355259 -Node: POSIX String Comparison358809 -Ref: POSIX String Comparison-Footnote-1359893 -Node: Boolean Ops360031 -Ref: Boolean Ops-Footnote-1364101 -Node: Conditional Exp364192 -Node: Function Calls365919 -Node: Precedence369799 -Node: Locales373468 -Node: Expressions Summary375099 -Node: Patterns and Actions377640 -Node: Pattern Overview378756 -Node: Regexp Patterns380433 -Node: Expression Patterns380976 -Node: Ranges384757 -Node: BEGIN/END387863 -Node: Using BEGIN/END388625 -Ref: Using BEGIN/END-Footnote-1391361 -Node: I/O And BEGIN/END391467 -Node: BEGINFILE/ENDFILE393738 -Node: Empty396669 -Node: Using Shell Variables396986 -Node: Action Overview399269 -Node: Statements401596 -Node: If Statement403444 -Node: While Statement404942 -Node: Do Statement406986 -Node: For Statement408142 -Node: Switch Statement411294 -Node: Break Statement413682 -Node: Continue Statement415723 -Node: Next Statement417548 -Node: Nextfile Statement419938 -Node: Exit Statement422574 -Node: Built-in Variables424978 -Node: User-modified426105 -Ref: User-modified-Footnote-1433794 -Node: Auto-set433856 -Ref: Auto-set-Footnote-1446438 -Ref: Auto-set-Footnote-2446643 -Node: ARGC and ARGV446699 -Node: Pattern Action Summary450603 -Node: Arrays452826 -Node: Array Basics454375 -Node: Array Intro455201 -Ref: figure-array-elements457174 -Node: Reference to Elements459581 -Node: Assigning Elements461960 -Node: Array Example462451 -Node: Scanning an Array464183 -Node: Controlling Scanning467184 -Ref: Controlling Scanning-Footnote-1472357 -Node: Delete472673 -Ref: Delete-Footnote-1475424 -Node: Numeric Array Subscripts475481 -Node: Uninitialized Subscripts477664 -Node: Multidimensional479289 -Node: Multiscanning482402 -Node: Arrays of Arrays483991 -Node: Arrays Summary488654 -Node: Functions490759 -Node: Built-in491632 -Node: Calling Built-in492710 -Node: Numeric Functions494698 -Ref: Numeric Functions-Footnote-1498732 -Ref: Numeric Functions-Footnote-2499089 -Ref: Numeric Functions-Footnote-3499137 -Node: String Functions499406 -Ref: String Functions-Footnote-1522403 -Ref: String Functions-Footnote-2522532 -Ref: String Functions-Footnote-3522780 -Node: Gory Details522867 -Ref: table-sub-escapes524640 -Ref: table-sub-proposed526160 -Ref: table-posix-sub527524 -Ref: table-gensub-escapes529064 -Ref: Gory Details-Footnote-1530240 -Node: I/O Functions530391 -Ref: I/O Functions-Footnote-1537501 -Node: Time Functions537648 -Ref: Time Functions-Footnote-1548112 -Ref: Time Functions-Footnote-2548180 -Ref: Time Functions-Footnote-3548338 -Ref: Time Functions-Footnote-4548449 -Ref: Time Functions-Footnote-5548561 -Ref: Time Functions-Footnote-6548788 -Node: Bitwise Functions549054 -Ref: table-bitwise-ops549616 -Ref: Bitwise Functions-Footnote-1553861 -Node: Type Functions554045 -Node: I18N Functions555187 -Node: User-defined556832 -Node: Definition Syntax557636 -Ref: Definition Syntax-Footnote-1562815 -Node: Function Example562884 -Ref: Function Example-Footnote-1565524 -Node: Function Caveats565546 -Node: Calling A Function566064 -Node: Variable Scope567019 -Node: Pass By Value/Reference570007 -Node: Return Statement573517 -Node: Dynamic Typing576501 -Node: Indirect Calls577430 -Node: Functions Summary587143 -Node: Library Functions589682 -Ref: Library Functions-Footnote-1593300 -Ref: Library Functions-Footnote-2593443 -Node: Library Names593614 -Ref: Library Names-Footnote-1597087 -Ref: Library Names-Footnote-2597307 -Node: General Functions597393 -Node: Strtonum Function598421 -Node: Assert Function601201 -Node: Round Function604527 -Node: Cliff Random Function606068 -Node: Ordinal Functions607084 -Ref: Ordinal Functions-Footnote-1610161 -Ref: Ordinal Functions-Footnote-2610413 -Node: Join Function610624 -Ref: Join Function-Footnote-1612395 -Node: Getlocaltime Function612595 -Node: Readfile Function616331 -Node: Data File Management618170 -Node: Filetrans Function618802 -Node: Rewind Function622871 -Node: File Checking624429 -Ref: File Checking-Footnote-1625561 -Node: Empty Files625762 -Node: Ignoring Assigns627741 -Node: Getopt Function629295 -Ref: Getopt Function-Footnote-1640598 -Node: Passwd Functions640801 -Ref: Passwd Functions-Footnote-1649780 -Node: Group Functions649868 -Ref: Group Functions-Footnote-1657809 -Node: Walking Arrays658022 -Node: Library Functions Summary659625 -Node: Library exercises661013 -Node: Sample Programs662293 -Node: Running Examples663063 -Node: Clones663791 -Node: Cut Program665015 -Node: Egrep Program674883 -Ref: Egrep Program-Footnote-1682854 -Node: Id Program682964 -Node: Split Program686628 -Ref: Split Program-Footnote-1690166 -Node: Tee Program690294 -Node: Uniq Program693101 -Node: Wc Program700531 -Ref: Wc Program-Footnote-1704796 -Node: Miscellaneous Programs704888 -Node: Dupword Program706101 -Node: Alarm Program708132 -Node: Translate Program712946 -Ref: Translate Program-Footnote-1717337 -Ref: Translate Program-Footnote-2717607 -Node: Labels Program717741 -Ref: Labels Program-Footnote-1721112 -Node: Word Sorting721196 -Node: History Sorting725239 -Node: Extract Program727075 -Node: Simple Sed734611 -Node: Igawk Program737673 -Ref: Igawk Program-Footnote-1751977 -Ref: Igawk Program-Footnote-2752178 -Node: Anagram Program752316 -Node: Signature Program755384 -Node: Programs Summary756631 -Node: Programs Exercises757846 -Node: Advanced Features761497 -Node: Nondecimal Data763445 -Node: Array Sorting765022 -Node: Controlling Array Traversal765719 -Node: Array Sorting Functions773999 -Ref: Array Sorting Functions-Footnote-1777906 -Node: Two-way I/O778100 -Ref: Two-way I/O-Footnote-1783044 -Ref: Two-way I/O-Footnote-2783223 -Node: TCP/IP Networking783305 -Node: Profiling786150 -Node: Advanced Features Summary793692 -Node: Internationalization795556 -Node: I18N and L10N797036 -Node: Explaining gettext797722 -Ref: Explaining gettext-Footnote-1802748 -Ref: Explaining gettext-Footnote-2802932 -Node: Programmer i18n803097 -Ref: Programmer i18n-Footnote-1807891 -Node: Translator i18n807940 -Node: String Extraction808734 -Ref: String Extraction-Footnote-1809867 -Node: Printf Ordering809953 -Ref: Printf Ordering-Footnote-1812735 -Node: I18N Portability812799 -Ref: I18N Portability-Footnote-1815248 -Node: I18N Example815311 -Ref: I18N Example-Footnote-1818017 -Node: Gawk I18N818089 -Node: I18N Summary818727 -Node: Debugger820066 -Node: Debugging821088 -Node: Debugging Concepts821529 -Node: Debugging Terms823385 -Node: Awk Debugging825982 -Node: Sample Debugging Session826874 -Node: Debugger Invocation827394 -Node: Finding The Bug828727 -Node: List of Debugger Commands835209 -Node: Breakpoint Control836541 -Node: Debugger Execution Control840205 -Node: Viewing And Changing Data843565 -Node: Execution Stack846923 -Node: Debugger Info848436 -Node: Miscellaneous Debugger Commands852430 -Node: Readline Support857614 -Node: Limitations858506 -Node: Debugging Summary860780 -Node: Arbitrary Precision Arithmetic861948 -Node: Computer Arithmetic863435 -Ref: Computer Arithmetic-Footnote-1867822 -Node: Math Definitions867879 -Ref: table-ieee-formats871168 -Ref: Math Definitions-Footnote-1871708 -Node: MPFR features871811 -Node: FP Math Caution873428 -Ref: FP Math Caution-Footnote-1874478 -Node: Inexactness of computations874847 -Node: Inexact representation875795 -Node: Comparing FP Values877150 -Node: Errors accumulate878114 -Node: Getting Accuracy879547 -Node: Try To Round882206 -Node: Setting precision883105 -Ref: table-predefined-precision-strings883787 -Node: Setting the rounding mode885580 -Ref: table-gawk-rounding-modes885944 -Ref: Setting the rounding mode-Footnote-1889398 -Node: Arbitrary Precision Integers889577 -Ref: Arbitrary Precision Integers-Footnote-1892558 -Node: POSIX Floating Point Problems892707 -Ref: POSIX Floating Point Problems-Footnote-1896583 -Node: Floating point summary896621 -Node: Dynamic Extensions898825 -Node: Extension Intro900377 -Node: Plugin License901642 -Node: Extension Mechanism Outline902327 -Ref: figure-load-extension902751 -Ref: figure-load-new-function904236 -Ref: figure-call-new-function905238 -Node: Extension API Description907222 -Node: Extension API Functions Introduction908672 -Node: General Data Types913539 -Ref: General Data Types-Footnote-1919232 -Node: Requesting Values919531 -Ref: table-value-types-returned920268 -Node: Memory Allocation Functions921226 -Ref: Memory Allocation Functions-Footnote-1923973 -Node: Constructor Functions924069 -Node: Registration Functions925827 -Node: Extension Functions926512 -Node: Exit Callback Functions928814 -Node: Extension Version String930062 -Node: Input Parsers930712 -Node: Output Wrappers940526 -Node: Two-way processors945042 -Node: Printing Messages947246 -Ref: Printing Messages-Footnote-1948323 -Node: Updating `ERRNO'948475 -Node: Accessing Parameters949214 -Node: Symbol Table Access950444 -Node: Symbol table by name950958 -Node: Symbol table by cookie952934 -Ref: Symbol table by cookie-Footnote-1957067 -Node: Cached values957130 -Ref: Cached values-Footnote-1960634 -Node: Array Manipulation960725 -Ref: Array Manipulation-Footnote-1961823 -Node: Array Data Types961862 -Ref: Array Data Types-Footnote-1964565 -Node: Array Functions964657 -Node: Flattening Arrays968531 -Node: Creating Arrays975383 -Node: Extension API Variables980114 -Node: Extension Versioning980750 -Node: Extension API Informational Variables982651 -Node: Extension API Boilerplate983737 -Node: Finding Extensions987541 -Node: Extension Example988101 -Node: Internal File Description988831 -Node: Internal File Ops992922 -Ref: Internal File Ops-Footnote-11004354 -Node: Using Internal File Ops1004494 -Ref: Using Internal File Ops-Footnote-11006841 -Node: Extension Samples1007109 -Node: Extension Sample File Functions1008633 -Node: Extension Sample Fnmatch1016201 -Node: Extension Sample Fork1017683 -Node: Extension Sample Inplace1018896 -Node: Extension Sample Ord1020571 -Node: Extension Sample Readdir1021407 -Ref: table-readdir-file-types1022263 -Node: Extension Sample Revout1023062 -Node: Extension Sample Rev2way1023653 -Node: Extension Sample Read write array1024394 -Node: Extension Sample Readfile1026273 -Node: Extension Sample API Tests1027373 -Node: Extension Sample Time1027898 -Node: gawkextlib1029213 -Node: Extension summary1032026 -Node: Extension Exercises1035719 -Node: Language History1036441 -Node: V7/SVR3.11038084 -Node: SVR41040404 -Node: POSIX1041846 -Node: BTL1043232 -Node: POSIX/GNU1043966 -Node: Feature History1049682 -Node: Common Extensions1062773 -Node: Ranges and Locales1064085 -Ref: Ranges and Locales-Footnote-11068702 -Ref: Ranges and Locales-Footnote-21068729 -Ref: Ranges and Locales-Footnote-31068963 -Node: Contributors1069184 -Node: History summary1074609 -Node: Installation1075978 -Node: Gawk Distribution1076929 -Node: Getting1077413 -Node: Extracting1078237 -Node: Distribution contents1079879 -Node: Unix Installation1085596 -Node: Quick Installation1086213 -Node: Additional Configuration Options1088655 -Node: Configuration Philosophy1090393 -Node: Non-Unix Installation1092744 -Node: PC Installation1093202 -Node: PC Binary Installation1094513 -Node: PC Compiling1096361 -Ref: PC Compiling-Footnote-11099360 -Node: PC Testing1099465 -Node: PC Using1100641 -Node: Cygwin1104793 -Node: MSYS1105602 -Node: VMS Installation1106116 -Node: VMS Compilation1106912 -Ref: VMS Compilation-Footnote-11108134 -Node: VMS Dynamic Extensions1108192 -Node: VMS Installation Details1109565 -Node: VMS Running1111817 -Node: VMS GNV1114651 -Node: VMS Old Gawk1115374 -Node: Bugs1115844 -Node: Other Versions1119848 -Node: Installation summary1126075 -Node: Notes1127131 -Node: Compatibility Mode1127996 -Node: Additions1128778 -Node: Accessing The Source1129703 -Node: Adding Code1131139 -Node: New Ports1137317 -Node: Derived Files1141798 -Ref: Derived Files-Footnote-11146879 -Ref: Derived Files-Footnote-21146913 -Ref: Derived Files-Footnote-31147509 -Node: Future Extensions1147623 -Node: Implementation Limitations1148229 -Node: Extension Design1149477 -Node: Old Extension Problems1150631 -Ref: Old Extension Problems-Footnote-11152148 -Node: Extension New Mechanism Goals1152205 -Ref: Extension New Mechanism Goals-Footnote-11155565 -Node: Extension Other Design Decisions1155754 -Node: Extension Future Growth1157860 -Node: Old Extension Mechanism1158696 -Node: Notes summary1160458 -Node: Basic Concepts1161644 -Node: Basic High Level1162325 -Ref: figure-general-flow1162597 -Ref: figure-process-flow1163196 -Ref: Basic High Level-Footnote-11166425 -Node: Basic Data Typing1166610 -Node: Glossary1169938 -Node: Copying1195090 -Node: GNU Free Documentation License1232646 -Node: Index1257782 +Ref: When-Footnote-1109847 +Node: Intro Summary109912 +Node: Invoking Gawk110795 +Node: Command Line112310 +Node: Options113101 +Ref: Options-Footnote-1128877 +Node: Other Arguments128902 +Node: Naming Standard Input131564 +Node: Environment Variables132657 +Node: AWKPATH Variable133215 +Ref: AWKPATH Variable-Footnote-1136081 +Ref: AWKPATH Variable-Footnote-2136126 +Node: AWKLIBPATH Variable136386 +Node: Other Environment Variables137145 +Node: Exit Status140802 +Node: Include Files141477 +Node: Loading Shared Libraries145055 +Node: Obsolete146439 +Node: Undocumented147136 +Node: Invoking Summary147403 +Node: Regexp149003 +Node: Regexp Usage150462 +Node: Escape Sequences152495 +Node: Regexp Operators158312 +Ref: Regexp Operators-Footnote-1165830 +Ref: Regexp Operators-Footnote-2165977 +Node: Bracket Expressions166075 +Ref: table-char-classes168097 +Node: GNU Regexp Operators171037 +Node: Case-sensitivity174746 +Ref: Case-sensitivity-Footnote-1177638 +Ref: Case-sensitivity-Footnote-2177873 +Node: Leftmost Longest177981 +Node: Computed Regexps179182 +Node: Regexp Summary182554 +Node: Reading Files184023 +Node: Records186115 +Node: awk split records186837 +Node: gawk split records191695 +Ref: gawk split records-Footnote-1196216 +Node: Fields196253 +Ref: Fields-Footnote-1199217 +Node: Nonconstant Fields199303 +Ref: Nonconstant Fields-Footnote-1201533 +Node: Changing Fields201735 +Node: Field Separators207689 +Node: Default Field Splitting210391 +Node: Regexp Field Splitting211508 +Node: Single Character Fields214835 +Node: Command Line Field Separator215894 +Node: Full Line Fields219320 +Ref: Full Line Fields-Footnote-1219828 +Node: Field Splitting Summary219874 +Ref: Field Splitting Summary-Footnote-1223006 +Node: Constant Size223107 +Node: Splitting By Content227713 +Ref: Splitting By Content-Footnote-1231786 +Node: Multiple Line231826 +Ref: Multiple Line-Footnote-1237682 +Node: Getline237861 +Node: Plain Getline240072 +Node: Getline/Variable242167 +Node: Getline/File243314 +Node: Getline/Variable/File244698 +Ref: Getline/Variable/File-Footnote-1246297 +Node: Getline/Pipe246384 +Node: Getline/Variable/Pipe249070 +Node: Getline/Coprocess250177 +Node: Getline/Variable/Coprocess251429 +Node: Getline Notes252166 +Node: Getline Summary254970 +Ref: table-getline-variants255378 +Node: Read Timeout256290 +Ref: Read Timeout-Footnote-1260117 +Node: Command-line directories260175 +Node: Input Summary261079 +Node: Input Exercises264216 +Node: Printing264949 +Node: Print266671 +Node: Print Examples268164 +Node: Output Separators270943 +Node: OFMT272959 +Node: Printf274317 +Node: Basic Printf275223 +Node: Control Letters276762 +Node: Format Modifiers280753 +Node: Printf Examples286780 +Node: Redirection289244 +Node: Special Files296216 +Node: Special FD296749 +Ref: Special FD-Footnote-1300346 +Node: Special Network300420 +Node: Special Caveats301270 +Node: Close Files And Pipes302066 +Ref: Close Files And Pipes-Footnote-1309227 +Ref: Close Files And Pipes-Footnote-2309375 +Node: Output Summary309525 +Node: Output exercises310522 +Node: Expressions311202 +Node: Values312387 +Node: Constants313063 +Node: Scalar Constants313743 +Ref: Scalar Constants-Footnote-1314602 +Node: Nondecimal-numbers314852 +Node: Regexp Constants317852 +Node: Using Constant Regexps318327 +Node: Variables321399 +Node: Using Variables322054 +Node: Assignment Options323778 +Node: Conversion325653 +Node: Strings And Numbers326177 +Ref: Strings And Numbers-Footnote-1329239 +Node: Locale influences conversions329348 +Ref: table-locale-affects332065 +Node: All Operators332653 +Node: Arithmetic Ops333283 +Node: Concatenation335788 +Ref: Concatenation-Footnote-1338607 +Node: Assignment Ops338713 +Ref: table-assign-ops343696 +Node: Increment Ops344999 +Node: Truth Values and Conditions348437 +Node: Truth Values349520 +Node: Typing and Comparison350569 +Node: Variable Typing351362 +Node: Comparison Operators355014 +Ref: table-relational-ops355424 +Node: POSIX String Comparison358974 +Ref: POSIX String Comparison-Footnote-1360058 +Node: Boolean Ops360196 +Ref: Boolean Ops-Footnote-1364271 +Node: Conditional Exp364362 +Node: Function Calls366089 +Node: Precedence369969 +Node: Locales373638 +Node: Expressions Summary375269 +Node: Patterns and Actions377810 +Node: Pattern Overview378926 +Node: Regexp Patterns380603 +Node: Expression Patterns381146 +Node: Ranges384926 +Node: BEGIN/END388032 +Node: Using BEGIN/END388794 +Ref: Using BEGIN/END-Footnote-1391530 +Node: I/O And BEGIN/END391636 +Node: BEGINFILE/ENDFILE393907 +Node: Empty396838 +Node: Using Shell Variables397155 +Node: Action Overview399438 +Node: Statements401765 +Node: If Statement403613 +Node: While Statement405111 +Node: Do Statement407155 +Node: For Statement408311 +Node: Switch Statement411463 +Node: Break Statement413851 +Node: Continue Statement415892 +Node: Next Statement417717 +Node: Nextfile Statement420107 +Node: Exit Statement422743 +Node: Built-in Variables425147 +Node: User-modified426274 +Ref: User-modified-Footnote-1433963 +Node: Auto-set434025 +Ref: Auto-set-Footnote-1446607 +Ref: Auto-set-Footnote-2446812 +Node: ARGC and ARGV446868 +Node: Pattern Action Summary450772 +Node: Arrays452995 +Node: Array Basics454544 +Node: Array Intro455370 +Ref: figure-array-elements457343 +Node: Reference to Elements459750 +Node: Assigning Elements462200 +Node: Array Example462691 +Node: Scanning an Array464423 +Node: Controlling Scanning467424 +Ref: Controlling Scanning-Footnote-1472597 +Node: Delete472913 +Ref: Delete-Footnote-1475664 +Node: Numeric Array Subscripts475721 +Node: Uninitialized Subscripts477904 +Node: Multidimensional479529 +Node: Multiscanning482642 +Node: Arrays of Arrays484231 +Node: Arrays Summary488894 +Node: Functions490999 +Node: Built-in491872 +Node: Calling Built-in492950 +Node: Numeric Functions494938 +Ref: Numeric Functions-Footnote-1498972 +Ref: Numeric Functions-Footnote-2499329 +Ref: Numeric Functions-Footnote-3499377 +Node: String Functions499646 +Ref: String Functions-Footnote-1522643 +Ref: String Functions-Footnote-2522772 +Ref: String Functions-Footnote-3523020 +Node: Gory Details523107 +Ref: table-sub-escapes524880 +Ref: table-sub-proposed526400 +Ref: table-posix-sub527764 +Ref: table-gensub-escapes529304 +Ref: Gory Details-Footnote-1530480 +Node: I/O Functions530631 +Ref: I/O Functions-Footnote-1537741 +Node: Time Functions537888 +Ref: Time Functions-Footnote-1548352 +Ref: Time Functions-Footnote-2548420 +Ref: Time Functions-Footnote-3548578 +Ref: Time Functions-Footnote-4548689 +Ref: Time Functions-Footnote-5548801 +Ref: Time Functions-Footnote-6549028 +Node: Bitwise Functions549294 +Ref: table-bitwise-ops549856 +Ref: Bitwise Functions-Footnote-1554101 +Node: Type Functions554285 +Node: I18N Functions555427 +Node: User-defined557072 +Node: Definition Syntax557876 +Ref: Definition Syntax-Footnote-1563055 +Node: Function Example563124 +Ref: Function Example-Footnote-1565764 +Node: Function Caveats565786 +Node: Calling A Function566304 +Node: Variable Scope567259 +Node: Pass By Value/Reference570247 +Node: Return Statement573757 +Node: Dynamic Typing576741 +Node: Indirect Calls577670 +Node: Functions Summary587383 +Node: Library Functions589922 +Ref: Library Functions-Footnote-1593540 +Ref: Library Functions-Footnote-2593683 +Node: Library Names593854 +Ref: Library Names-Footnote-1597327 +Ref: Library Names-Footnote-2597547 +Node: General Functions597633 +Node: Strtonum Function598661 +Node: Assert Function601441 +Node: Round Function604767 +Node: Cliff Random Function606308 +Node: Ordinal Functions607324 +Ref: Ordinal Functions-Footnote-1610389 +Ref: Ordinal Functions-Footnote-2610641 +Node: Join Function610852 +Ref: Join Function-Footnote-1612623 +Node: Getlocaltime Function612823 +Node: Readfile Function616559 +Node: Data File Management618398 +Node: Filetrans Function619030 +Node: Rewind Function623099 +Node: File Checking624657 +Ref: File Checking-Footnote-1625789 +Node: Empty Files625990 +Node: Ignoring Assigns627969 +Node: Getopt Function629523 +Ref: Getopt Function-Footnote-1640826 +Node: Passwd Functions641029 +Ref: Passwd Functions-Footnote-1650008 +Node: Group Functions650096 +Ref: Group Functions-Footnote-1658027 +Node: Walking Arrays658240 +Node: Library Functions Summary659843 +Node: Library exercises661231 +Node: Sample Programs662511 +Node: Running Examples663281 +Node: Clones664009 +Node: Cut Program665233 +Node: Egrep Program675091 +Ref: Egrep Program-Footnote-1682678 +Node: Id Program682788 +Node: Split Program686442 +Ref: Split Program-Footnote-1689980 +Node: Tee Program690108 +Node: Uniq Program692895 +Node: Wc Program700316 +Ref: Wc Program-Footnote-1704581 +Node: Miscellaneous Programs704673 +Node: Dupword Program705886 +Node: Alarm Program707917 +Node: Translate Program712721 +Ref: Translate Program-Footnote-1717112 +Ref: Translate Program-Footnote-2717382 +Node: Labels Program717516 +Ref: Labels Program-Footnote-1720877 +Node: Word Sorting720961 +Node: History Sorting725004 +Node: Extract Program726840 +Node: Simple Sed734376 +Node: Igawk Program737438 +Ref: Igawk Program-Footnote-1751742 +Ref: Igawk Program-Footnote-2751943 +Node: Anagram Program752081 +Node: Signature Program755149 +Node: Programs Summary756396 +Node: Programs Exercises757611 +Node: Advanced Features761262 +Node: Nondecimal Data763210 +Node: Array Sorting764787 +Node: Controlling Array Traversal765484 +Node: Array Sorting Functions773764 +Ref: Array Sorting Functions-Footnote-1777671 +Node: Two-way I/O777865 +Ref: Two-way I/O-Footnote-1782809 +Ref: Two-way I/O-Footnote-2782988 +Node: TCP/IP Networking783070 +Node: Profiling785915 +Node: Advanced Features Summary793457 +Node: Internationalization795321 +Node: I18N and L10N796801 +Node: Explaining gettext797487 +Ref: Explaining gettext-Footnote-1802513 +Ref: Explaining gettext-Footnote-2802697 +Node: Programmer i18n802862 +Ref: Programmer i18n-Footnote-1807656 +Node: Translator i18n807705 +Node: String Extraction808499 +Ref: String Extraction-Footnote-1809632 +Node: Printf Ordering809718 +Ref: Printf Ordering-Footnote-1812500 +Node: I18N Portability812564 +Ref: I18N Portability-Footnote-1815013 +Node: I18N Example815076 +Ref: I18N Example-Footnote-1817782 +Node: Gawk I18N817854 +Node: I18N Summary818492 +Node: Debugger819831 +Node: Debugging820853 +Node: Debugging Concepts821294 +Node: Debugging Terms823150 +Node: Awk Debugging825747 +Node: Sample Debugging Session826639 +Node: Debugger Invocation827159 +Node: Finding The Bug828492 +Node: List of Debugger Commands834974 +Node: Breakpoint Control836306 +Node: Debugger Execution Control839970 +Node: Viewing And Changing Data843330 +Node: Execution Stack846688 +Node: Debugger Info848201 +Node: Miscellaneous Debugger Commands852195 +Node: Readline Support857379 +Node: Limitations858271 +Node: Debugging Summary860545 +Node: Arbitrary Precision Arithmetic861713 +Node: Computer Arithmetic863200 +Ref: Computer Arithmetic-Footnote-1867587 +Node: Math Definitions867644 +Ref: table-ieee-formats870933 +Ref: Math Definitions-Footnote-1871473 +Node: MPFR features871576 +Node: FP Math Caution873193 +Ref: FP Math Caution-Footnote-1874243 +Node: Inexactness of computations874612 +Node: Inexact representation875560 +Node: Comparing FP Values876915 +Node: Errors accumulate877879 +Node: Getting Accuracy879312 +Node: Try To Round881971 +Node: Setting precision882870 +Ref: table-predefined-precision-strings883552 +Node: Setting the rounding mode885345 +Ref: table-gawk-rounding-modes885709 +Ref: Setting the rounding mode-Footnote-1889163 +Node: Arbitrary Precision Integers889342 +Ref: Arbitrary Precision Integers-Footnote-1892323 +Node: POSIX Floating Point Problems892472 +Ref: POSIX Floating Point Problems-Footnote-1896348 +Node: Floating point summary896386 +Node: Dynamic Extensions898590 +Node: Extension Intro900142 +Node: Plugin License901407 +Node: Extension Mechanism Outline902092 +Ref: figure-load-extension902516 +Ref: figure-load-new-function904001 +Ref: figure-call-new-function905003 +Node: Extension API Description906987 +Node: Extension API Functions Introduction908437 +Node: General Data Types913304 +Ref: General Data Types-Footnote-1918997 +Node: Requesting Values919296 +Ref: table-value-types-returned920033 +Node: Memory Allocation Functions920991 +Ref: Memory Allocation Functions-Footnote-1923738 +Node: Constructor Functions923834 +Node: Registration Functions925592 +Node: Extension Functions926277 +Node: Exit Callback Functions928579 +Node: Extension Version String929827 +Node: Input Parsers930477 +Node: Output Wrappers940291 +Node: Two-way processors944807 +Node: Printing Messages947011 +Ref: Printing Messages-Footnote-1948088 +Node: Updating `ERRNO'948240 +Node: Accessing Parameters948979 +Node: Symbol Table Access950209 +Node: Symbol table by name950723 +Node: Symbol table by cookie952699 +Ref: Symbol table by cookie-Footnote-1956832 +Node: Cached values956895 +Ref: Cached values-Footnote-1960399 +Node: Array Manipulation960490 +Ref: Array Manipulation-Footnote-1961588 +Node: Array Data Types961627 +Ref: Array Data Types-Footnote-1964330 +Node: Array Functions964422 +Node: Flattening Arrays968296 +Node: Creating Arrays975148 +Node: Extension API Variables979879 +Node: Extension Versioning980515 +Node: Extension API Informational Variables982416 +Node: Extension API Boilerplate983502 +Node: Finding Extensions987306 +Node: Extension Example987866 +Node: Internal File Description988596 +Node: Internal File Ops992687 +Ref: Internal File Ops-Footnote-11004119 +Node: Using Internal File Ops1004259 +Ref: Using Internal File Ops-Footnote-11006606 +Node: Extension Samples1006874 +Node: Extension Sample File Functions1008398 +Node: Extension Sample Fnmatch1015966 +Node: Extension Sample Fork1017448 +Node: Extension Sample Inplace1018661 +Node: Extension Sample Ord1020336 +Node: Extension Sample Readdir1021172 +Ref: table-readdir-file-types1022028 +Node: Extension Sample Revout1022827 +Node: Extension Sample Rev2way1023418 +Node: Extension Sample Read write array1024159 +Node: Extension Sample Readfile1026038 +Node: Extension Sample API Tests1027138 +Node: Extension Sample Time1027663 +Node: gawkextlib1028978 +Node: Extension summary1031791 +Node: Extension Exercises1035484 +Node: Language History1036206 +Node: V7/SVR3.11037849 +Node: SVR41040169 +Node: POSIX1041611 +Node: BTL1042997 +Node: POSIX/GNU1043731 +Node: Feature History1049447 +Node: Common Extensions1062538 +Node: Ranges and Locales1063850 +Ref: Ranges and Locales-Footnote-11068467 +Ref: Ranges and Locales-Footnote-21068494 +Ref: Ranges and Locales-Footnote-31068728 +Node: Contributors1068949 +Node: History summary1074374 +Node: Installation1075743 +Node: Gawk Distribution1076694 +Node: Getting1077178 +Node: Extracting1078002 +Node: Distribution contents1079644 +Node: Unix Installation1085361 +Node: Quick Installation1085978 +Node: Additional Configuration Options1088420 +Node: Configuration Philosophy1090158 +Node: Non-Unix Installation1092509 +Node: PC Installation1092967 +Node: PC Binary Installation1094278 +Node: PC Compiling1096126 +Ref: PC Compiling-Footnote-11099125 +Node: PC Testing1099230 +Node: PC Using1100406 +Node: Cygwin1104558 +Node: MSYS1105367 +Node: VMS Installation1105881 +Node: VMS Compilation1106677 +Ref: VMS Compilation-Footnote-11107899 +Node: VMS Dynamic Extensions1107957 +Node: VMS Installation Details1109330 +Node: VMS Running1111582 +Node: VMS GNV1114416 +Node: VMS Old Gawk1115139 +Node: Bugs1115609 +Node: Other Versions1119613 +Node: Installation summary1125840 +Node: Notes1126896 +Node: Compatibility Mode1127761 +Node: Additions1128543 +Node: Accessing The Source1129468 +Node: Adding Code1130904 +Node: New Ports1137082 +Node: Derived Files1141563 +Ref: Derived Files-Footnote-11146644 +Ref: Derived Files-Footnote-21146678 +Ref: Derived Files-Footnote-31147274 +Node: Future Extensions1147388 +Node: Implementation Limitations1147994 +Node: Extension Design1149242 +Node: Old Extension Problems1150396 +Ref: Old Extension Problems-Footnote-11151913 +Node: Extension New Mechanism Goals1151970 +Ref: Extension New Mechanism Goals-Footnote-11155330 +Node: Extension Other Design Decisions1155519 +Node: Extension Future Growth1157625 +Node: Old Extension Mechanism1158461 +Node: Notes summary1160223 +Node: Basic Concepts1161409 +Node: Basic High Level1162090 +Ref: figure-general-flow1162362 +Ref: figure-process-flow1162961 +Ref: Basic High Level-Footnote-11166190 +Node: Basic Data Typing1166375 +Node: Glossary1169703 +Node: Copying1194855 +Node: GNU Free Documentation License1232411 +Node: Index1257547 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 86a0c4c2..deda30b7 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 @@ -4731,7 +4734,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 @@ -5257,12 +5260,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. @@ -5421,6 +5423,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) @@ -6045,7 +6050,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 @@ -6112,16 +6117,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. @@ -7910,7 +7912,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 @@ -12264,7 +12266,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}). @@ -12923,7 +12925,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 @@ -15551,6 +15553,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}: @@ -20813,8 +20817,7 @@ function chr(c) @c endfile #### test code #### -# BEGIN \ -# @{ +# BEGIN @{ # for (;;) @{ # printf("enter a character: ") # if (getline var <= 0) @@ -22371,8 +22374,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/" @} @@ -22949,8 +22951,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) @{ @@ -23425,8 +23426,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 @@ -23450,17 +23450,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 @@ -23527,8 +23516,7 @@ numbers: # egid=5(blat) groups=9(nine),2(two),1(one) @group -BEGIN \ -@{ +BEGIN @{ uid = PROCINFO["uid"] euid = PROCINFO["euid"] gid = PROCINFO["gid"] @@ -23798,8 +23786,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] @@ -23861,8 +23848,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]) @} @@ -23979,8 +23965,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:" @@ -24499,8 +24484,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]) @@ -24895,8 +24879,7 @@ function printpage( i, j) Count++ @} -END \ -@{ +END @{ printpage() @} @c endfile diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 9eccea7b..efd9e05b 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 @@ -4659,7 +4662,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 @@ -5102,12 +5105,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. @@ -5266,6 +5268,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) @@ -5846,7 +5851,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 @@ -5913,16 +5918,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. @@ -7529,7 +7531,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 @@ -11615,7 +11617,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}). @@ -12274,7 +12276,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 @@ -14856,6 +14858,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}: @@ -19957,8 +19961,7 @@ function chr(c) @c endfile #### test code #### -# BEGIN \ -# @{ +# BEGIN @{ # for (;;) @{ # printf("enter a character: ") # if (getline var <= 0) @@ -21486,8 +21489,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/" @} @@ -22064,8 +22066,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) @{ @@ -22540,8 +22541,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 @@ -22565,17 +22565,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 @@ -22642,8 +22631,7 @@ numbers: # egid=5(blat) groups=9(nine),2(two),1(one) @group -BEGIN \ -@{ +BEGIN @{ uid = PROCINFO["uid"] euid = PROCINFO["euid"] gid = PROCINFO["gid"] @@ -22913,8 +22901,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] @@ -22976,8 +22963,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]) @} @@ -23094,8 +23080,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:" @@ -23614,8 +23599,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]) @@ -24010,8 +23994,7 @@ function printpage( i, j) Count++ @} -END \ -@{ +END @{ printpage() @} @c endfile |