diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-09-21 22:31:17 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-09-21 22:31:17 +0300 |
commit | eff1b6b21720518f2ea9dbd862fe3844d899db08 (patch) | |
tree | 12480b28b523ca72deb58dc00b325eb3c7113cf3 | |
parent | 4dcc853c04e05a88e2c07125bf3e7ab75cbcb6ca (diff) | |
download | egawk-eff1b6b21720518f2ea9dbd862fe3844d899db08.tar.gz egawk-eff1b6b21720518f2ea9dbd862fe3844d899db08.tar.bz2 egawk-eff1b6b21720518f2ea9dbd862fe3844d899db08.zip |
Doc fixes.
-rw-r--r-- | doc/ChangeLog | 4 | ||||
-rw-r--r-- | doc/gawk.info | 1817 | ||||
-rw-r--r-- | doc/gawk.texi | 529 | ||||
-rw-r--r-- | doc/gawktexi.in | 514 |
4 files changed, 1461 insertions, 1403 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index 72d907ca..01f9b3ed 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2014-09-21 Arnold D. Robbins <arnold@skeeve.com> + + * gawktex.in: Start on fixes after reading through the MS. + 2014-09-18 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Fix italics in quotations. Some docbook special diff --git a/doc/gawk.info b/doc/gawk.info index 42465c42..c4809a63 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -14,7 +14,7 @@ Free Software Foundation, Inc. This is Edition 4.1 of `GAWK: Effective AWK Programming: A User's -Guide for GNU Awk', for the 4.1.1 (or later) version of the GNU +Guide for GNU Awk', for the 4.1.2 (or later) version of the GNU implementation of AWK. Permission is granted to copy, distribute and/or modify this document @@ -42,7 +42,7 @@ Free Software Foundation, Inc. This is Edition 4.1 of `GAWK: Effective AWK Programming: A User's -Guide for GNU Awk', for the 4.1.1 (or later) version of the GNU +Guide for GNU Awk', for the 4.1.2 (or later) version of the GNU implementation of AWK. Permission is granted to copy, distribute and/or modify this document @@ -693,7 +693,7 @@ on Unix, I found the gray AWK book, a.k.a. Aho, Kernighan and Weinberger, `The AWK Programming Language', Addison-Wesley, 1988. AWK's simple programming paradigm--find a pattern in the input and then perform an action--often reduced complex or tedious data manipulations -to few lines of code. I was excited to try my hand at programming in +to a few lines of code. I was excited to try my hand at programming in AWK. Alas, the `awk' on my computer was a limited version of the @@ -779,8 +779,8 @@ with the proper options or environment variables (*note Options::), it is fully compatible with the POSIX(1) specification of the `awk' language and with the Unix version of `awk' maintained by Brian Kernighan. This means that all properly written `awk' programs should -work with `gawk'. Thus, we usually don't distinguish between `gawk' -and other `awk' implementations. +work with `gawk'. So most of the time, we don't distinguish between +`gawk' and other `awk' implementations. Using `awk' allows you to: @@ -803,9 +803,9 @@ and other `awk' implementations. * Perform simple network communications - * Profile and debug `awk' programs. + * Profile and debug `awk' programs - * Extend the language with functions written in C or C++. + * Extend the language with functions written in C or C++ This Info file teaches you about the `awk' language and how you can use it effectively. You should already be familiar with basic system @@ -818,9 +818,8 @@ different computing environments. This Info file, while describing the of `awk' called `gawk' (which stands for "GNU `awk'"). `gawk' runs on a broad range of Unix systems, ranging from Intel-architecture PC-based computers up through large-scale systems. `gawk' has also been ported -to Mac OS X, Microsoft Windows (all versions) and OS/2 PCs, and OpenVMS. -(Some other, obsolete systems to which `gawk' was once ported are no -longer supported and the code for those systems has been removed.) +to Mac OS X, Microsoft Windows (all versions) and OS/2 PCs, and +OpenVMS.(3) * Menu: @@ -840,11 +839,14 @@ longer supported and the code for those systems has been removed.) (1) The 2008 POSIX standard is accessible online at `http://www.opengroup.org/onlinepubs/9699919799/'. - (2) These commands are available on POSIX-compliant systems, as well -as on traditional Unix-based systems. If you are using some other + (2) These utilities are available on POSIX-compliant systems, as +well as on traditional Unix-based systems. If you are using some other operating system, you still need to be familiar with the ideas of I/O redirection and pipes. + (3) Some other, obsolete systems to which `gawk' was once ported are +no longer supported and the code for those systems has been removed. + File: gawk.info, Node: History, Next: Names, Up: Preface @@ -958,7 +960,7 @@ heading "sidebar." Most of the time, the examples use complete `awk' programs. Some of the more advanced sections show only the part of the `awk' program that -illustrates the concept currently being described. +illustrates the concept being described. While this Info file is aimed principally at people who have not been exposed to `awk', there is a lot of information here that even the `awk' @@ -1002,7 +1004,8 @@ described, as well as sorting arrays in `gawk'. It also describes how `gawk' provides arrays of arrays. *note Functions::, describes the built-in functions `awk' and `gawk' -provide, as well as how to define your own functions. +provide, as well as how to define your own functions. It also +discusses how `gawk' lets you call functions indirectly. Part II shows how to use `awk' and `gawk' for problem solving. There is lots of code here for you to read and learn from. It contains @@ -1457,21 +1460,21 @@ advice (from Douglas Adams's `The Hitchhiker's Guide to the Galaxy'), to keep you from worrying about the complexities of computer programming: - $ awk "BEGIN { print "Don\47t Panic!" }" + $ awk 'BEGIN { print "Don\47t Panic!" }' -| Don't Panic! `awk' executes statements associated with `BEGIN' before reading any input. If there are no other statements in your program, as is the case here, `awk' just stops, instead of trying to read input it doesn't -know how to process. The `\47' is a magic way of getting a single -quote into the program, without having to engage in ugly shell quoting -tricks. +know how to process. The `\47' is a magic way (explained later) of +getting a single quote into the program, without having to engage in +ugly shell quoting tricks. - NOTE: As a side note, if you use Bash as your shell, you should - execute the command `set +H' before running this program - interactively, to disable the C shell-style command history, which - treats `!' as a special character. We recommend putting this - command into your personal startup file. + NOTE: If you use Bash as your shell, you should execute the + command `set +H' before running this program interactively, to + disable the C shell-style command history, which treats `!' as a + special character. We recommend putting this command into your + personal startup file. This next simple `awk' program emulates the `cat' utility; it copies whatever you type on the keyboard to its standard output (why this @@ -1494,9 +1497,9 @@ File: gawk.info, Node: Long, Next: Executable Scripts, Prev: Read Terminal, 1.1.3 Running Long Programs --------------------------- -Sometimes your `awk' programs can be very long. In this case, it is -more convenient to put the program into a separate file. In order to -tell `awk' to use that file for its program, you type: +Sometimes `awk' programs are very long. In these cases, it is more +convenient to put the program into a separate file. In order to tell +`awk' to use that file for its program, you type: awk -f SOURCE-FILE INPUT-FILE1 INPUT-FILE2 ... @@ -1512,14 +1515,16 @@ into the file `advice'. Then this command: does the same thing as this one: - awk "BEGIN { print \"Don't Panic!\" }" + awk 'BEGIN { print "Don\47t Panic!" }' This was explained earlier (*note Read Terminal::). Note that you don't usually need single quotes around the file name that you specify with `-f', because most file names don't contain any of the shell's special characters. Notice that in `advice', the `awk' program did not have single quotes around it. The quotes are only needed for programs -that are provided on the `awk' command line. +that are provided on the `awk' command line. (Also, placing the +program in a file allows us to use a literal single quote in the program +text, instead of the magic `\47'.) If you want to clearly identify your `awk' program files as such, you can add the extension `.awk' to the file name. This doesn't affect @@ -1563,7 +1568,7 @@ program is written in `awk'. utility reads your program and then processes your data according to the instructions in your program. (This is different from a "compiled" language such as C, where your program is first compiled into machine -code that is executed directly by your system's hardware.) The `awk' +code that is executed directly by your system's processor.) The `awk' utility is thus termed an "interpreter". Many modern languages are interperted. @@ -1573,8 +1578,8 @@ to pass to that interpreter. The operating system then runs the interpreter with the given argument and the full argument list of the executed program. The first argument in the list is the full file name of the `awk' program. The rest of the argument list contains either -options to `awk', or data files, or both. Note that on many systems -`awk' may be found in `/usr/bin' instead of in `/bin'. Caveat Emptor. +options to `awk', or data files, or both. (Note that on many systems +`awk' may be found in `/usr/bin' instead of in `/bin'.) Some systems limit the length of the interpreter name to 32 characters. Often, this can be dealt with by using a symbolic link. @@ -1714,8 +1719,11 @@ the quoting rules. the characters `$', ``', `\', and `"', all of which must be preceded by a backslash within double-quoted text if they are to be passed on literally to the program. (The leading backslash is - stripped first.) Thus, the example seen in *note Read Terminal::, - is applicable: + stripped first.) Thus, the example seen in *note Read Terminal::: + + awk 'BEGIN { print "Don\47t Panic!" }' + + could instead be written this way: $ awk "BEGIN { print \"Don't Panic!\" }" -| Don't Panic! @@ -1781,6 +1789,9 @@ this: $ awk -v sq="'" 'BEGIN { print "Here is a single quote <" sq ">" }' -| Here is a single quote <'> + (Here, the two string constants and the value of `sq' are +concatenated into a single string which is printed by `print'.) + If you really need both single and double quotes in your `awk' program, it is probably best to move it into a separate file, where the shell won't be part of the picture, and you can say what you mean. @@ -1816,12 +1827,12 @@ The second data file, called `inventory-shipped', contains information about monthly shipments. In both files, each line is considered to be one "record". - In the data file `mail-list', each record contains the name of a -person, his/her phone number, his/her email-address, and a code for -their relationship with the author of the list. The columns are -aligned using spaces. An `A' in the last column means that the person -is an acquaintance. An `F' in the last column means that the person is -a friend. An `R' means that the person is a relative: + In `mail-list', each record contains the name of a person, his/her +phone number, his/her email-address, and a code for their relationship +with the author of the list. The columns are aligned using spaces. An +`A' in the last column means that the person is an acquaintance. An +`F' in the last column means that the person is a friend. An `R' means +that the person is a relative: Amelia 555-5553 amelia.zodiacusque@gmail.com F Anthony 555-3412 anthony.asserturo@hotmail.com A @@ -1939,7 +1950,7 @@ different ways to do the same things shown here: * Print the length of the longest line in `data': expand data | awk '{ if (x < length($0)) x = length($0) } - END { print "maximum line length is " x }' + END { print "maximum line length is " x }' This example differs slightly from the previous one: The input is processed by the `expand' utility to change TABs into spaces, so @@ -1962,7 +1973,7 @@ different ways to do the same things shown here: * Print the total number of bytes used by FILES: ls -l FILES | awk '{ x += $5 } - END { print "total bytes: " x }' + END { print "total bytes: " x }' * Print the total number of kilobytes used by FILES: @@ -1991,13 +2002,13 @@ File: gawk.info, Node: Two Rules, Next: More Complex, Prev: Very Simple, Up: ============================= The `awk' utility reads the input files one line at a time. For each -line, `awk' tries the patterns of each of the rules. If several -patterns match, then several actions execute in the order in which they -appear in the `awk' program. If no patterns match, then no actions run. +line, `awk' tries the patterns of each rule. If several patterns +match, then several actions execute in the order in which they appear +in the `awk' program. If no patterns match, then no actions run. After processing all the rules that match the line (and perhaps there are none), `awk' reads the next line. (However, *note Next -Statement::, and also *note Nextfile Statement::). This continues +Statement::, and also *note Nextfile Statement::.) This continues until the program reaches the end of the file. For example, the following `awk' program contains two rules: @@ -2061,11 +2072,11 @@ date the file was last modified. Its output looks like this: The first field contains read-write permissions, the second field contains the number of links to the file, and the third field -identifies the owner of the file. The fourth field identifies the group -of the file. The fifth field contains the size of the file in bytes. -The sixth, seventh, and eighth fields contain the month, day, and time, +identifies the file's owner. The fourth field identifies the file's +group. The fifth field contains the file's size in bytes. The sixth, +seventh, and eighth fields contain the month, day, and time, respectively, that the file was last modified. Finally, the ninth field -contains the file name.(1) +contains the file name. The `$6 == "Nov"' in our `awk' program is an expression that tests whether the sixth field of the output from `ls -l' matches the string @@ -2087,11 +2098,6 @@ displays your output. By manipulating fields and using `print' statements, you can produce some very useful and impressive-looking reports. - ---------- Footnotes ---------- - - (1) The `LC_ALL=C' is needed to produce this traditional-style -output from `ls'. - File: gawk.info, Node: Statements/Lines, Next: Other Features, Prev: More Complex, Up: Getting Started @@ -2388,7 +2394,7 @@ The following list describes options mandated by the POSIX standard: CAUTION: Using `-v' to set the values of the built-in variables may lead to surprising results. `awk' will reset the values of those variables as it needs to, possibly - ignoring any predefined value you may have given. + ignoring any initial value you may have given. `-W GAWK-OPT' Provide an implementation-specific option. This is the POSIX @@ -2439,9 +2445,9 @@ The following list describes options mandated by the POSIX standard: `-d'[FILE] `--dump-variables'[`='FILE] Print a sorted list of global variables, their types, and final - values to FILE. If no FILE is provided, print this list to the - file named `awkvars.out' in the current directory. No space is - allowed between the `-d' and FILE, if FILE is supplied. + values to FILE. If no FILE is provided, print this list to a file + named `awkvars.out' in the current directory. No space is allowed + between the `-d' and FILE, if FILE is supplied. Having a list of all global variables is a good way to look for typographical errors in your programs. You would also use this @@ -2504,7 +2510,7 @@ The following list describes options mandated by the POSIX standard: `-i' SOURCE-FILE `--include' SOURCE-FILE - Read `awk' source library from SOURCE-FILE. This option is + Read an `awk' source library from SOURCE-FILE. This option is completely equivalent to using the `@include' directive inside your program. This option is very similar to the `-f' option, but there are two important differences. First, when `-i' is used, @@ -2525,8 +2531,8 @@ The following list describes options mandated by the POSIX standard: not be specified in the extension name. The extension initialization routine should be named `dl_load()'. An alternative is to use the `@load' keyword inside the program to - load a shared library. This feature is described in detail in - *note Dynamic Extensions::. + load a shared library. This advanced feature is described in + detail in *note Dynamic Extensions::. `-L'[VALUE] `--lint'[`='VALUE] @@ -2663,8 +2669,9 @@ it is, `awk' reads its program source from all of the named files, as if they had been concatenated together into one big file. This is useful for creating libraries of `awk' functions. These functions can be written once and then retrieved from a standard place, instead of -having to be included into each individual program. (As mentioned in -*note Definition Syntax::, function names must be unique.) +having to be included into each individual program. The `-i' option is +similar in this regard. (As mentioned in *note Definition Syntax::, +function names must be unique.) With standard `awk', library functions can still be used, even if the program is entered at the keyboard, by specifying `-f /dev/tty'. @@ -2721,14 +2728,17 @@ Any additional arguments on the command line are normally treated as input files to be processed in the order specified. However, an argument that has the form `VAR=VALUE', assigns the value VALUE to the variable VAR--it does not specify a file at all. (See *note Assignment -Options::.) +Options::.) In the following example, COUNT=1 is a variable assignment, +not a file name: + + awk -f program.awk file1 count=1 file2 - All these arguments are made available to your `awk' program in the -`ARGV' array (*note Built-in Variables::). Command-line options and -the program text (if present) are omitted from `ARGV'. All other -arguments, including variable assignments, are included. As each -element of `ARGV' is processed, `gawk' sets the variable `ARGIND' to -the index in `ARGV' of the current element. + All the command-line arguments are made available to your `awk' +program in the `ARGV' array (*note Built-in Variables::). Command-line +options and the program text (if present) are omitted from `ARGV'. All +other arguments, including variable assignments, are included. As +each element of `ARGV' is processed, `gawk' sets the variable `ARGIND' +to the index in `ARGV' of the current element. Changing `ARGC' and `ARGV' in your `awk' program lets you control how `awk' processes the input files; this is described in more detail @@ -2837,8 +2847,8 @@ variable. If that variable does not exist, `gawk' uses a default path, The search path feature is particularly helpful for building libraries of useful `awk' functions. The library files can be placed in a standard directory in the default path and then specified on the -command line with a short file name. Otherwise, the full file name -would have to be typed for each file. +command line with a short file name. Otherwise, you would have to type +the full file name for each file. By using the `-i' option, or the `-e' and `-f' options, your command-line `awk' programs can use facilities in `awk' library files @@ -2846,21 +2856,20 @@ command-line `awk' programs can use facilities in `awk' library files in compatibility mode. This is true for both `--traditional' and `--posix'. *Note Options::. - If the source code is not found after the initial search, the path -is searched again after adding the default `.awk' suffix to the file -name. + If the source code file is not found after the initial search, the +path is searched again after adding the default `.awk' suffix to the +file name. - NOTE: To include the current directory in the path, either place - `.' explicitly in the path or write a null entry in the path. (A - null entry is indicated by starting or ending the path with a - colon or by placing two colons next to each other [`::'].) This - path search mechanism is similar to the shell's. (See `The - Bourne-Again SHell manual'. - (http://www.gnu.org/software/bash/manual/)) + `gawk''s path search mechanism is similar to the shell's. (See `The +Bourne-Again SHell manual' (http://www.gnu.org/software/bash/manual/).) +It treats a null entry in the path as indicating the current directory. +(A null entry is indicated by starting or ending the path with a colon +or by placing two colons next to each other [`::'].) - However, `gawk' always looks in the current directory _before_ - searching `AWKPATH', so there is no real reason to include the - current directory in the search path. + NOTE: `gawk' always looks in the current directory _before_ + searching `AWKPATH'. Thus, while you can include the current + directory in the search path, either explicitly or with a null + entry, there is no real reason to do so. If `AWKPATH' is not defined in the environment, `gawk' places its default search path into `ENVIRON["AWKPATH"]'. This makes it easy to @@ -2907,15 +2916,6 @@ A number of other environment variables affect `gawk''s behavior, but they are more specialized. Those in the following list are meant to be used by regular users. -`POSIXLY_CORRECT' - Causes `gawk' to switch to POSIX compatibility mode, disabling all - traditional and GNU extensions. *Note Options::. - -`GAWK_SOCK_RETRIES' - Controls the number of times `gawk' attempts to retry a two-way - TCP/IP (socket) connection before giving up. *Note TCP/IP - Networking::. - `GAWK_MSEC_SLEEP' Specifies the interval between connection retries, in milliseconds. On systems that do not support the `usleep()' system @@ -2925,6 +2925,15 @@ used by regular users. Specifies the time, in milliseconds, for `gawk' to wait for input before returning with an error. *Note Read Timeout::. +`GAWK_SOCK_RETRIES' + Controls the number of times `gawk' attempts to retry a two-way + TCP/IP (socket) connection before giving up. *Note TCP/IP + Networking::. + +`POSIXLY_CORRECT' + Causes `gawk' to switch to POSIX compatibility mode, disabling all + traditional and GNU extensions. *Note Options::. + The environment variables in the following list are meant for use by the `gawk' developers for testing and tuning. They are subject to change. The variables are: @@ -2936,7 +2945,7 @@ change. The variables are: the value should be a number, and `gawk' uses that number as the size of the buffer to allocate. (When this variable is not set, `gawk' uses the smaller of the file's size and the "default" - blocksize, which is usually the filesystems I/O blocksize.) + blocksize, which is usually the filesystem's I/O blocksize.) `AWK_HASH' If this variable exists with a value of `gst', `gawk' switches to @@ -2950,11 +2959,11 @@ change. The variables are: where I/O is performed in records, not in blocks. `GAWK_MSG_SRC' - If this variable exists, `gawk' includes the source file name and - line number from which warning and/or fatal messages are - generated. Its purpose is to help isolate the source of a - message, since there can be multiple places which produce the same - warning or error message. + If this variable exists, `gawk' includes the file name and line + number within the `gawk' source code from which warning and/or + fatal messages are generated. Its purpose is to help isolate the + source of a message, since there are multiple places which produce + the same warning or error message. `GAWK_NO_DFA' If this variable exists, `gawk' does not use the DFA regexp matcher @@ -2966,8 +2975,10 @@ change. The variables are: `GAWK_NO_PP_RUN' If this variable exists, then when invoked with the - `--pretty-print' option, `gawk' skips running the program. This - variable will not survive into the next major release. + `--pretty-print' option, `gawk' skips running the program. + + CAUTION: This variable will not survive into the next major + release. `GAWK_STACKSIZE' This specifies the amount by which `gawk' should grow its internal @@ -3133,7 +3144,8 @@ is useful for embedding inside an `awk' source file that requires access to an extension. *note Dynamic Extensions::, describes how to write extensions (in C -or C++) that can be loaded with either `@load' or the `-l' option. +or C++) that can be loaded with either `@load' or the `-l' option. It +also describes the `ordchr' extension. File: gawk.info, Node: Obsolete, Next: Undocumented, Prev: Loading Shared Libraries, Up: Invoking Gawk @@ -3184,7 +3196,8 @@ File: gawk.info, Node: Invoking Summary, Prev: Undocumented, Up: Invoking Gaw affects how `awk' processes input. * You can use a single minus sign (`-') to refer to standard input - on the command line. + on the command line. `gawk' also lets you use the special file + name `/dev/stdin'. * `gawk' pays attention to a number of environment variables. `AWKPATH', `AWKLIBPATH', and `POSIXLY_CORRECT' are the most @@ -3322,9 +3335,9 @@ or newline. While there is nothing to stop you from entering most unprintable characters directly in a string constant or regexp constant, they may look ugly. - The following table lists all the escape sequences used in `awk' and -what they represent. Unless noted otherwise, all these escape sequences -apply to both string constants and regexp constants: + The following list presents all the escape sequences used in `awk' +and what they represent. Unless noted otherwise, all these escape +sequences apply to both string constants and regexp constants: `\\' A literal backslash, `\'. @@ -3396,11 +3409,11 @@ normally be a regexp operator. For example, `/a\+b/' matches the three characters `a+b'. For complete portability, do not use a backslash before any -character not shown in the previous list. +character not shown in the previous list and that is not an operator. To summarize: - * The escape sequences in the table above are always processed first, + * The escape sequences in the list above are always processed first, for both string constants and regexp constants. This happens very early, as soon as `awk' reads your program. @@ -3458,7 +3471,7 @@ and converted into corresponding real characters as the very first step in processing regexps. Here is a list of metacharacters. All characters that are not escape -sequences and that are not listed in the table stand for themselves: +sequences and that are not listed in the following stand for themselves: `\' This is used to suppress the special meaning of a character when @@ -3646,8 +3659,8 @@ 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 + The treatment of `\' in bracket expressions is compatible with other +`awk' implementations and is also mandated by POSIX. The regular expressions in `awk' are a superset of the POSIX specification for Extended Regular Expressions (EREs). POSIX EREs are based on the regular expressions accepted by the traditional `egrep' utility. @@ -3735,10 +3748,11 @@ Consider the following: echo aaaabcd | awk '{ sub(/a+/, "<A>"); print }' - This example uses the `sub()' function (which we haven't discussed -yet; *note String Functions::) to make a change to the input record. -Here, the regexp `/a+/' indicates "one or more `a' characters," and the -replacement text is `<A>'. + This example uses the `sub()' function to make a change to the input +record. (`sub()' replaces the first instance of any text matched by +the first argument with the string provided as the second argument; +*note String Functions::). Here, the regexp `/a+/' indicates "one or +more `a' characters," and the replacement text is `<A>'. The input contains four `a' characters. `awk' (and POSIX) regular expressions always match the leftmost, _longest_ sequence of input @@ -3814,15 +3828,15 @@ constants," for several reasons: Using `\n' in Bracket Expressions of Dynamic Regexps - Some versions of `awk' do not allow the newline character to be used -inside a bracket expression for a dynamic regexp: + Some older versions of `awk' do not allow the newline character to +be used inside a bracket expression for a dynamic regexp: $ awk '$0 ~ "[ \t\n]"' error--> awk: newline in character class [ error--> ]... error--> source line number 1 error--> context is - error--> >>> <<< + error--> $0 ~ "[ >>> \t\n]" <<< But a newline in a regexp constant works with no problem: @@ -4030,10 +4044,6 @@ File: gawk.info, Node: Regexp Summary, Prev: Case-sensitivity, Up: Regexp Within bracket expressions, POSIX character classes let you specify certain groups of characters in a locale-independent fashion. - * `gawk''s `IGNORECASE' variable lets you control the case - sensitivity of regexp matching. In other `awk' versions, use - `tolower()' or `toupper()'. - * Regular expressions match the leftmost longest text in the string being matched. This matters for cases where you need to know the extent of the match, such as for text substitution and when the @@ -4042,6 +4052,10 @@ File: gawk.info, Node: Regexp Summary, Prev: Case-sensitivity, Up: Regexp * Matching expressions may use dynamic regexps, that is, string values treated as regular expressions. + * `gawk''s `IGNORECASE' variable lets you control the case + sensitivity of regexp matching. In other `awk' versions, use + `tolower()' or `toupper()'. + File: gawk.info, Node: Reading Files, Next: Printing, Prev: Regexp, Up: Top @@ -4095,7 +4109,7 @@ File: gawk.info, Node: Records, Next: Fields, Up: Reading Files `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. +called `FNR' which is reset to zero every time 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. @@ -4203,9 +4217,10 @@ character such as `/' is more likely to produce correct behavior in the majority of cases, but there are no guarantees. The moral is: Know Your Data. - There is one unusual case, that occurs when `gawk' is being fully -POSIX-compliant (*note Options::). Then, the following (extreme) -pipeline prints a surprising `1': + When using regular characters as the record separator, there is one +unusual case that occurs when `gawk' is being fully POSIX-compliant +(*note Options::). Then, the following (extreme) pipeline prints a +surprising `1': $ echo | gawk --posix 'BEGIN { RS = "a" } ; { print NF }' -| 1 @@ -4270,9 +4285,9 @@ trailing whitespace: -| ] The square brackets delineate the contents of `RT', letting you see the -leading and trailing whitespace. The final value of `RT' `RT' is a -newline. *Note Simple Sed::, for a more useful example of `RS' as a -regexp and `RT'. +leading and trailing whitespace. The final value of `RT' is a newline. +*Note Simple Sed::, for a more useful example of `RS' as a regexp and +`RT'. If you set `RS' to a regular expression that allows optional trailing text, such as `RS = "abc(XYZ)?"' it is possible, due to @@ -4287,13 +4302,13 @@ that this will never happen. the beginning and end of a _line_. As a result, something like `RS = "^[[:upper:]]"' can only match at the beginning of a file. This is because `gawk' views the input file as one long string - that happens to contain newline characters in it. It is thus best - to avoid anchor characters in the value of `RS'. + that happens to contain newline characters. It is thus best to + avoid anchor characters in the value of `RS'. The use of `RS' as a regular expression and the `RT' variable are `gawk' extensions; they are not available in compatibility mode (*note Options::). In compatibility mode, only the first character of the -value of `RS' is used to determine the end of the record. +value of `RS' determines the end of the record. `RS = "\0"' Is Not Portable @@ -4322,11 +4337,12 @@ terminator. In effect, this means that `RS = "\0"' is the same as `RS It happens that recent versions of `mawk' can use the NUL character as a record separator. However, this is a special case: `mawk' does not -allow embedded NUL characters in strings. +allow embedded NUL characters in strings. (This may change in a future +version of `mawk'.) - *Note Readfile Function::, for an interesting, portable way to read -whole files. If you are using `gawk', see *note Extension Sample -Readfile::, for another option. + *Note Readfile Function::, for an interesting way to read whole +files. If you are using `gawk', see *note Extension Sample Readfile::, +for another option. ---------- Footnotes ---------- @@ -4383,13 +4399,11 @@ examples: -| Julie 555-6699 julie.perscrutabor@skeeve.com F This example prints each record in the file `mail-list' whose first -field contains the string `li'. The operator `~' is called a "matching -operator" (*note Regexp Usage::); it tests whether a string (here, the -field `$1') matches a given regular expression. +field contains the string `li'. By contrast, the following example looks for `li' in _the entire -record_ and prints the first field and the last field for each matching -input record: +record_ and prints the first and last fields for each matching input +record: $ awk '/li/ { print $1, $NF }' mail-list -| Amelia F @@ -4565,12 +4579,12 @@ value six. value of `NF' and recomputes `$0'. (d.c.) Here is an example: $ echo a b c d e f | awk '{ print "NF =", NF; - > NF = 3; print $0 }' + > NF = 3; print $0 }' -| NF = 6 -| a b c CAUTION: Some versions of `awk' don't rebuild `$0' when `NF' is - decremented. Caveat emptor. + decremented. Finally, there are times when it is convenient to force `awk' to rebuild the entire record, using the current value of the fields and @@ -4595,8 +4609,8 @@ as it was read from the input. This includes any leading or trailing whitespace, and the exact whitespace (or other characters) that separate the fields. - It is a not-uncommon error to try to change the field separators in -a record simply by setting `FS' and `OFS', and then expecting a plain + It is a common error to try to change the field separators in a +record simply by setting `FS' and `OFS', and then expecting a plain `print' or `print $0' to print the modified record. But this does not work, since nothing was done to change the record @@ -4746,9 +4760,9 @@ play whenever `$0' is recomputed. For instance, study this pipeline: The first `print' statement prints the record as it was read, with leading whitespace intact. The assignment to `$2' rebuilds `$0' by concatenating `$1' through `$NF' together, separated by the value of -`OFS'. Because the leading whitespace was ignored when finding `$1', -it is not part of the new `$0'. Finally, the last `print' statement -prints the new `$0'. +`OFS' (which is a space by default). Because the leading whitespace +was ignored when finding `$1', it is not part of the new `$0'. +Finally, the last `print' statement prints the new `$0'. There is an additional subtlety to be aware of when using regular expressions for field splitting. It is not well-specified in the POSIX @@ -4763,7 +4777,7 @@ beginning of the record. `gawk' also works this way. For example: $ echo 'xxAA xxBxx C' | > gawk -F '(^x+)|( +)' '{ for (i = 1; i <= NF; i++) - > printf "-->%s<--\n", $i }' + > printf "-->%s<--\n", $i }' -| --><-- -| -->AA<-- -| -->xxBxx<-- @@ -4808,10 +4822,7 @@ For example: sets `FS' to the `,' character. Notice that the option uses an uppercase `F' instead of a lowercase `f'. The latter option (`-f') -specifies a file containing an `awk' program. Case is significant in -command-line options: the `-F' and `-f' options have nothing to do with -each other. You can use both options at the same time to set the `FS' -variable _and_ get an `awk' program from a file. +specifies a file containing an `awk' program. The value used for the argument to `-F' is processed in exactly the same way as assignments to the built-in variable `FS'. Any special @@ -4909,7 +4920,7 @@ occurrences of any two characters." If instead you want fields to be separated by a literal period followed by any single character, use `FS = "\\.."'. - The following table summarizes how fields are split, based on the + The following list summarizes how fields are split, based on the value of `FS' (`==' means "is equal to"): `FS == " "' @@ -4929,7 +4940,7 @@ value of `FS' (`==' means "is equal to"): `FS == ""' Each individual character in the record becomes a separate field. - (This is a `gawk' extension; it is not specified by the POSIX + (This is a common extension; it is not specified by the POSIX standard.) Changing `FS' Does Not Affect the Fields @@ -5300,7 +5311,7 @@ A simple program to process this file is as follows: ... *Note Labels Program::, for a more realistic program that deals with -address lists. The following table summarizes how records are split, +address lists. The following list summarizes how records are split, based on the value of `RS'. (`==' means "is equal to.") `RS == "\n"' @@ -5324,9 +5335,10 @@ based on the value of `RS'. (`==' means "is equal to.") records. (This is a `gawk' extension; it is not specified by the POSIX standard.) - In all cases, `gawk' sets `RT' to the input text that matched the -value specified by `RS'. But if the input file ended without any text -that matches `RS', then `gawk' sets `RT' to the null string. + If not in compatibility mode (*note Options::), `gawk' sets `RT' to +the input text that matched the value specified by `RS'. But if the +input file ended without any text that matches `RS', then `gawk' sets +`RT' to the null string. ---------- Footnotes ---------- @@ -5405,9 +5417,7 @@ processing on the next record _right now_. For example: while (j == 0) { # get more text if (getline <= 0) { - m = "unexpected EOF or error" - m = (m ": " ERRNO) - print m > "/dev/stderr" + print("unexpected EOF or error:", ERRNO) > "/dev/stderr" exit } # build up the line using string concatenation @@ -5610,9 +5620,9 @@ the program might produce: bill ttyp1 Jul 13 14:23 (murphy:0) bletch -Notice that this program ran the command `who' and printed the previous -result. (If you try this program yourself, you will of course get -different results, depending upon who is logged in on your system.) +Notice that this program ran the command `who' and printed the result. +(If you try this program yourself, you will of course get different +results, depending upon who is logged in on your system.) This variation of `getline' splits the record into fields, sets the value of `NF', and recomputes the value of `$0'. The values of `NR' @@ -5628,10 +5638,10 @@ all `awk' implementations. NOTE: Unfortunately, `gawk' has not been consistent in its treatment of a construct like `"echo " "date" | getline'. Most versions, including the current version, treat it at as `("echo " - "date") | getline'. (This how BWK `awk' behaves.) Some versions - changed and treated it as `"echo " ("date" | getline)'. (This is - how `mawk' behaves.) In short, _always_ use explicit parentheses, - and then you won't have to worry. + "date") | getline'. (This is also how BWK `awk' behaves.) Some + versions changed and treated it as `"echo " ("date" | getline)'. + (This is how `mawk' behaves.) In short, _always_ use explicit + parentheses, and then you won't have to worry. File: gawk.info, Node: Getline/Variable/Pipe, Next: Getline/Coprocess, Prev: Getline/Pipe, Up: Getline @@ -5651,7 +5661,7 @@ following program reads the current date and time into the variable } In this version of `getline', none of the built-in variables are -changed and the record is not split into fields. +changed and the record is not split into fields. However, `RT' is set. According to POSIX, `EXPRESSION | getline VAR' is ambiguous if EXPRESSION contains unparenthesized operators other than `$'; for @@ -5733,7 +5743,7 @@ in mind: `getline' command causes `awk' to set the value of `FILENAME'. Normally, `FILENAME' does not have a value inside `BEGIN' rules, because you have not yet started to process the command-line data - files. (d.c.) (*Note BEGIN/END::, also *note Auto-set::.) + files. (d.c.) (See *note BEGIN/END::; also *note Auto-set::.) * Using `FILENAME' with `getline' (`getline < FILENAME') is likely to be a source for confusion. `awk' opens a separate input stream @@ -5766,7 +5776,7 @@ in mind: `gawk' treats `getline' like a function call, and evaluates the expression `a[++c]' before attempting to read from `f'. However, some versions of `awk' only evaluate the expression once they know - that there is a string value to be assigned. Caveat Emptor. + that there is a string value to be assigned. File: gawk.info, Node: Getline Summary, Prev: Getline Notes, Up: Getline @@ -5779,19 +5789,18 @@ File: gawk.info, Node: Getline Summary, Prev: Getline Notes, Up: Getline whether the variant is standard or a `gawk' extension. Note: for each variant, `gawk' sets the `RT' built-in variable. -Variant Effect Standard / - Extension +Variant Effect `awk' / `gawk' ------------------------------------------------------------------------- -`getline' Sets `$0', `NF', `FNR', Standard +`getline' Sets `$0', `NF', `FNR', `awk' `NR', and `RT' -`getline' VAR Sets VAR, `FNR', `NR', and Standard +`getline' VAR Sets VAR, `FNR', `NR', and `awk' `RT' -`getline <' FILE Sets `$0', `NF', and `RT' Standard -`getline VAR < FILE' Sets VAR and `RT' Standard -COMMAND `| getline' Sets `$0', `NF', and `RT' Standard -COMMAND `| getline' VAR Sets VAR and `RT' Standard -COMMAND `|& getline' Sets `$0', `NF', and `RT' Extension -COMMAND `|& getline' Sets VAR and `RT' Extension +`getline <' FILE Sets `$0', `NF', and `RT' `awk' +`getline VAR < FILE' Sets VAR and `RT' `awk' +COMMAND `| getline' Sets `$0', `NF', and `RT' `awk' +COMMAND `| getline' VAR Sets VAR and `RT' `awk' +COMMAND `|& getline' Sets `$0', `NF', and `RT' `gawk' +COMMAND `|& getline' Sets VAR and `RT' `gawk' VAR Table 4.1: `getline' Variants and What They Set @@ -5807,7 +5816,7 @@ This minor node describes a feature that is specific to `gawk'. You may specify a timeout in milliseconds for reading input from the keyboard, a pipe, or two-way communication, including TCP/IP sockets. This can be done on a per input, command or connection basis, by -setting a special element in the `PROCINFO' (*note Auto-set::) array: +setting a special element in the `PROCINFO' array (*note Auto-set::): PROCINFO["input_name", "READ_TIMEOUT"] = TIMEOUT IN MILLISECONDS @@ -5831,9 +5840,9 @@ for more than five seconds: print $0 `gawk' terminates the read operation if input does not arrive after -waiting for the timeout period, returns failure and sets the `ERRNO' -variable to an appropriate string value. A negative or zero value for -the timeout is the same as specifying no timeout at all. +waiting for the timeout period, returns failure and sets `ERRNO' to an +appropriate string value. A negative or zero value for the timeout is +the same as specifying no timeout at all. A timeout can also be set for reading from the keyboard in the implicit loop that reads input records and matches them against @@ -5931,6 +5940,10 @@ File: gawk.info, Node: Input Summary, Next: Input Exercises, Prev: Command-li A regexp Text that matches the `gawk' regexp + * `FNR' indicates how many records have been read from the current + input file; `NR' indicates how many records have been read in + total. + * `gawk' sets `RT' to the text matched by `RS'. * After splitting the input into records, `awk' further splits the @@ -5948,32 +5961,31 @@ File: gawk.info, Node: Input Summary, Next: Input Exercises, Prev: Command-li * Field splitting is more complicated than record splitting. - Field separator value Fields are split ... `awk' / - `gawk' + Field separator value Fields are split ... `awk' / + `gawk' ---------------------------------------------------------------------- - `FS == " "' On runs of whitespace `awk' - `FS == ANY SINGLE On that character `awk' - CHARACTER' - `FS == REGEXP' On text matching the `awk' - regexp - `FS == ""' Each individual character `gawk' - is a separate field - `FIELDWIDTHS == LIST OF Based on character `gawk' - COLUMNS' position - `FPAT == REGEXP' On text around text `gawk' - matching the regexp - - Using `FS = "\n"' causes the entire record to be a single field + `FS == " "' On runs of whitespace `awk' + `FS == ANY SINGLE On that character `awk' + CHARACTER' + `FS == REGEXP' On text matching the regexp `awk' + `FS == ""' Each individual character is `gawk' + a separate field + `FIELDWIDTHS == LIST OF Based on character position `gawk' + COLUMNS' + `FPAT == REGEXP' On the text surrounding text `gawk' + matching the regexp + + * Using `FS = "\n"' causes the entire record to be a single field (assuming that newlines separate records). * `FS' may be set from the command line using the `-F' option. This can also be done using command-line variable assignment. - * `PROCINFO["FS"]' can be used to see how fields are being split. + * Use `PROCINFO["FS"]' to see how fields are being split. * Use `getline' in its various forms to read additional records, from the default input stream, from a file, or from a pipe or - co-process. + coprocess. * Use `PROCINFO[FILE, "READ_TIMEOUT"]' to cause reads to timeout for FILE. @@ -6044,10 +6056,10 @@ File: gawk.info, Node: Print, Next: Print Examples, Up: Printing 5.1 The `print' Statement ========================= -The `print' statement is used for producing output with simple, -standardized formatting. You specify only the strings or numbers to -print, in a list separated by commas. They are output, separated by -single spaces, followed by a newline. The statement looks like this: +Use the `print' statement to produce output with simple, standardized +formatting. You specify only the strings or numbers to print, in a +list separated by commas. They are output, separated by single spaces, +followed by a newline. The statement looks like this: print ITEM1, ITEM2, ... @@ -6062,14 +6074,14 @@ Numeric values are converted to strings and then printed. The simple statement `print' with no items is equivalent to `print $0': it prints the entire current record. To print a blank line, use -`print ""', where `""' is the empty string. To print a fixed piece of -text, use a string constant, such as `"Don't Panic"', as one item. If -you forget to use the double-quote characters, your text is taken as an -`awk' expression, and you will probably get an error. Keep in mind -that a space is printed between any two items. +`print ""'. To print a fixed piece of text, use a string constant, +such as `"Don't Panic"', as one item. If you forget to use the +double-quote characters, your text is taken as an `awk' expression, and +you will probably get an error. Keep in mind that a space is printed +between any two items. Note that the `print' statement is a statement and not an -expression--you can't use it the pattern part of a pattern-action +expression--you can't use it in the pattern part of a PATTERN-ACTION statement, for example. @@ -6224,12 +6236,12 @@ to format numbers (or strings), and that there are a number of different ways in which numbers can be formatted. The different format specifications are discussed more fully in *note Control Letters::. - The built-in variable `OFMT' contains the default format -specification that `print' uses with `sprintf()' when it wants to -convert a number to a string for printing. The default value of `OFMT' -is `"%.6g"'. The way `print' prints numbers can be changed by -supplying different format specifications as the value of `OFMT', as -shown in the following example: + The built-in variable `OFMT' contains the format specification that +`print' uses with `sprintf()' when it wants to convert a number to a +string for printing. The default value of `OFMT' is `"%.6g"'. The way +`print' prints numbers can be changed by supplying a different format +specification for the value of `OFMT', as shown in the following +example: $ awk 'BEGIN { > OFMT = "%.0f" # print numbers as integers (rounds) @@ -6251,8 +6263,6 @@ by `print', use `printf'. With `printf' you can specify the width to use for each item, as well as various formatting choices for numbers (such as what output base to use, whether to print an exponent, whether to print a sign, and how many digits to print after the decimal point). -You do this by supplying a string, called the "format string", that -controls how and where to print the other arguments. * Menu: @@ -6271,10 +6281,10 @@ A simple `printf' statement looks like this: printf FORMAT, ITEM1, ITEM2, ... -The entire list of arguments may optionally be enclosed in parentheses. -The parentheses are necessary if any of the item expressions use the `>' -relational operator; otherwise, it can be confused with an output -redirection (*note Redirection::). +As print `print', the entire list of arguments may optionally be +enclosed in parentheses. Here too, the parentheses are necessary if any +of the item expressions use the `>' relational operator; otherwise, it +can be confused with an output redirection (*note Redirection::). The difference between `printf' and `print' is the FORMAT argument. This is an expression whose value is taken as a string; it specifies @@ -6295,10 +6305,10 @@ statements. For example: $ awk 'BEGIN { > ORS = "\nOUCH!\n"; OFS = "+" - > msg = "Dont Panic!" + > msg = "Don\47t Panic!" > printf "%s\n", msg > }' - -| Dont Panic! + -| Don't Panic! Here, neither the `+' nor the `OUCH' appear in the output message. @@ -6316,9 +6326,9 @@ print. The rest of the format specifier is made up of optional width. Here is a list of the format-control letters: `%c' - Print a number as an ASCII character; thus, `printf "%c", 65' - outputs the letter `A'. The output for a string value is the first - character of the string. + Print a number as a character; thus, `printf "%c", 65' outputs the + letter `A'. The output for a string value is the first character + of the string. NOTE: The POSIX standard says the first character of a string is printed. In locales with multibyte characters, `gawk' @@ -6411,7 +6421,7 @@ File: gawk.info, Node: Format Modifiers, Next: Printf Examples, Prev: Control A format specification can also include "modifiers" that can control how much of the item's value is printed, as well as how much space it gets. The modifiers come between the `%' and the format-control letter. -We will use the bullet symbol "*" in the following examples to represent +We use the bullet symbol "*" in the following examples to represent spaces in the output. Here are the possible modifiers, in the order in which they may appear: @@ -6431,8 +6441,7 @@ which they may appear: At first glance, this feature doesn't seem to be of much use. It is in fact a `gawk' extension, intended for use in translating messages at runtime. *Note Printf Ordering::, which describes how - and why to use positional specifiers. For now, we will not use - them. + and why to use positional specifiers. For now, we ignore them. `-' The minus sign, used before the width modifier (see later on in @@ -6462,10 +6471,10 @@ which they may appear: trailing zeros are not removed from the result. `0' - A leading `0' (zero) acts as a flag that indicates that output - should be padded with zeros instead of spaces. This applies only - to the numeric output formats. This flag only has an effect when - the field width is wider than the value to print. + A leading `0' (zero) acts as a flag indicating that output should + be padded with zeros instead of spaces. This applies only to the + numeric output formats. This flag only has an effect when the + field width is wider than the value to print. `'' A single quote or apostrophe character is a POSIX extension to ISO @@ -6613,14 +6622,14 @@ beginning of the `awk' program: awk 'BEGIN { print "Name Number" print "---- ------" } - { printf "%-10s %s\n", $1, $2 }' mail-list + { printf "%-10s %s\n", $1, $2 }' mail-list The above example mixes `print' and `printf' statements in the same program. Using just `printf' statements can produce the same results: awk 'BEGIN { printf "%-10s %s\n", "Name", "Number" printf "%-10s %s\n", "----", "------" } - { printf "%-10s %s\n", $1, $2 }' mail-list + { printf "%-10s %s\n", $1, $2 }' mail-list Printing each column heading with the same format specification used for the column elements ensures that the headings are aligned just like @@ -6632,7 +6641,7 @@ be emphasized by storing it in a variable, like this: awk 'BEGIN { format = "%-10s %s\n" printf format, "Name", "Number" printf format, "----", "------" } - { printf format, $1, $2 }' mail-list + { printf format, $1, $2 }' mail-list File: gawk.info, Node: Redirection, Next: Special Files, Prev: Printf, Up: Printing @@ -6645,7 +6654,7 @@ output, usually the screen. Both `print' and `printf' can also send their output to other places. This is called "redirection". NOTE: When `--sandbox' is specified (*note Options::), redirecting - output to files and pipes is disabled. + output to files, pipes and coprocesses is disabled. A redirection appears after the `print' or `printf' statement. Redirections in `awk' are written just like redirections in shell @@ -6716,16 +6725,10 @@ work identically for `printf': maintenance: report = "mail bug-system" - print "Awk script failed:", $0 | report - m = ("at record number " FNR " of " FILENAME) - print m | report + print("Awk script failed:", $0) | report + print("at record number", FNR, "of", FILENAME) | report close(report) - The message is built using string concatenation and saved in the - variable `m'. It's then sent down the pipeline to the `mail' - program. (The parentheses group the items to concatenate--see - *note Concatenation::.) - The `close()' function is called here because it's a good idea to close the pipe as soon as all the intended output has been sent to it. *Note Close Files And Pipes::, for more information. @@ -6798,8 +6801,8 @@ File: gawk.info, Node: Special Files, Next: Close Files And Pipes, Prev: Redi ================================ `gawk' provides a number of special file names that it interprets -internally. These file names provide access to standard file -descriptors and TCP/IP networking. +internally. These file names provide access to standard pre-opened +files and TCP/IP networking. * Menu: @@ -6810,8 +6813,8 @@ descriptors and TCP/IP networking. File: gawk.info, Node: Special FD, Next: Special Network, Up: Special Files -5.7.1 Special Files for Standard Descriptors --------------------------------------------- +5.7.1 Special Files for Standard Pre-Opened Files +------------------------------------------------- Running programs conventionally have three input and output streams already available to them for reading and writing. These are known as @@ -6839,19 +6842,20 @@ error messages to the screen, like this: (`/dev/tty' is a special file supplied by the operating system that is connected to your keyboard and screen. It represents the "terminal,"(1) which on modern systems is a keyboard and screen, not a serial console.) -This usually has the same effect but not always: although the standard -error stream is usually the screen, it can be redirected; when that -happens, writing to the screen is not correct. In fact, if `awk' is -run from a background job, it may not have a terminal at all. Then +This generally has the same effect but not always: although the +standard error stream is usually the screen, it can be redirected; when +that happens, writing to the screen is not correct. In fact, if `awk' +is run from a background job, it may not have a terminal at all. Then opening `/dev/tty' fails. `gawk' provides special file names for accessing the three standard streams. (c.e.) It also provides syntax for accessing any other -inherited open files. If the file name matches one of these special -names when `gawk' redirects input or output, then it directly uses the -stream that the file name stands for. These special file names work -for all operating systems that `gawk' has been ported to, not just -those that are POSIX-compliant: +inherited open files. These open files are often referred to by the +technical term "file descriptor". If the file name matches one of +these special names when `gawk' redirects input or output, then it +directly uses the descriptor that the file name stands for. These +special file names work for all operating systems that `gawk' has been +ported to, not just those that are POSIX-compliant: `/dev/stdin' The standard input (file descriptor 0). @@ -6916,8 +6920,8 @@ File: gawk.info, Node: Special Caveats, Prev: Special Network, Up: Special Fi 5.7.3 Special File Name Caveats ------------------------------- -Here is a list of things to bear in mind when using the special file -names that `gawk' provides: +Here are some things to bear in mind when using the special file names +that `gawk' provides: * Recognition of these special file names is disabled if `gawk' is in compatibility mode (*note Options::). @@ -7047,7 +7051,8 @@ addition, `gawk' sets `ERRNO' to a string indicating the error. Note also that `close(FILENAME)' has no "magic" effects on the implicit loop that reads through the files named on the command line. It is, more likely, a close of a file that was never opened with a -redirection, so `awk' silently does nothing. +redirection, so `awk' silently does nothing, except return a negative +value. When using the `|&' operator to communicate with a coprocess, it is occasionally useful to be able to close one end of the two-way pipe @@ -7056,8 +7061,8 @@ to `close()'. As in any other call to `close()', the first argument is the name of the command or special file used to start the coprocess. The second argument should be a string, with either of the values `"to"' or `"from"'. Case does not matter. As this is an advanced -feature, a more complete discussion is delayed until *note Two-way -I/O::, which discusses it in more detail and gives an example. +feature, discussion is delayed until *note Two-way I/O::, which +describes it in more detail and gives an example. Using `close()''s Return Value @@ -7113,13 +7118,13 @@ File: gawk.info, Node: Output Summary, Next: Output Exercises, Prev: Close Fi flags that modify the behavior of the format control letters. * Output from both `print' and `printf' may be redirected to files, - pipes, and co-processes. + pipes, and coprocesses. * `gawk' provides special file names for access to standard input, output and error, and for network communications. - * Use `close()' to close open file, pipe and co-process redirections. - For co-processes, it is possible to close only one direction of the + * Use `close()' to close open file, pipe and coprocess redirections. + For coprocesses, it is possible to close only one direction of the communications. @@ -8319,7 +8324,7 @@ Unless `b' happens to be zero or the null string, the `if' part of the test always succeeds. Because the operators are so similar, this kind of error is very difficult to spot when scanning the source code. - The following table of expressions illustrates the kind of comparison + The following list of expressions illustrates the kind of comparison `gawk' performs, as well as what the result of the comparison is: `1.5 <= 2.0' @@ -8685,7 +8690,7 @@ violates the precedence rules; for example, `$$0++--' is not a valid expression because the first `$' has higher precedence than the `++'; to avoid the problem the expression can be rewritten as `$($0++)--'. - This table presents `awk''s operators, in order of highest to lowest + This list presents `awk''s operators, in order of highest to lowest precedence: `('...`)' @@ -13196,7 +13201,7 @@ Nondecimal-numbers::), and then demonstrates the results of the (1) This example shows that 0's come in on the left side. For `gawk', this is always true, but in some languages, it's possible to -have the left side fill with 1's. Caveat emptor. +have the left side fill with 1's. File: gawk.info, Node: Type Functions, Next: I18N Functions, Prev: Bitwise Functions, Up: Built-in @@ -18579,7 +18584,7 @@ book. We provide some minimal explanations, but see a good shell programming book if you wish to understand things in more depth. (2) On some very old versions of `awk', the test `getline junk < t' -can loop forever if the file exists but is empty. Caveat emptor. +can loop forever if the file exists but is empty. File: gawk.info, Node: Anagram Program, Next: Signature Program, Prev: Igawk Program, Up: Miscellaneous Programs @@ -19256,7 +19261,7 @@ fill in the result array. Because `IGNORECASE' affects string comparisons, the value of `IGNORECASE' also affects sorting for both `asort()' and `asorti()'. Note also that the locale's sorting order does _not_ come into play; -comparisons are based on character values only.(1) Caveat Emptor. +comparisons are based on character values only.(1) ---------- Footnotes ---------- @@ -19716,9 +19721,9 @@ File: gawk.info, Node: Advanced Features Summary, Prev: Profiling, Up: Advanc `PROCINFO["sorted_in"]'. * You can use the `|&' operator to create a two-way pipe to a - co-process. You read from the co-process with `getline' and write + coprocess. You read from the coprocess with `getline' and write to it with `print' or `printf'. Use `close()' to close off the - co-process completely, or optionally, close off one side of the + coprocess completely, or optionally, close off one side of the two-way communications. * By using special "file names" with the `|&' operator, you can open @@ -26946,7 +26951,7 @@ There are two ways to get GNU software: supported. If you have the `wget' program, you can use a command like the following: - wget http://ftp.gnu.org/gnu/gawk/gawk-4.1.1.tar.gz + wget http://ftp.gnu.org/gnu/gawk/gawk-4.1.2.tar.gz The GNU software archive is mirrored around the world. The up-to-date list of mirror sites is available from the main FSF web site @@ -26965,25 +26970,25 @@ compression programs: `gzip', `bzip2', and `xz'. For simplicity, the rest of these instructions assume you are using the one compressed with the GNU Zip program, `gzip'. - Once you have the distribution (for example, `gawk-4.1.1.tar.gz'), + Once you have the distribution (for example, `gawk-4.1.2.tar.gz'), use `gzip' to expand the file and then use `tar' to extract it. You can use the following pipeline to produce the `gawk' distribution: - gzip -d -c gawk-4.1.1.tar.gz | tar -xvpf - + gzip -d -c gawk-4.1.2.tar.gz | tar -xvpf - On a system with GNU `tar', you can let `tar' do the decompression for you: - tar -xvpzf gawk-4.1.1.tar.gz + tar -xvpzf gawk-4.1.2.tar.gz -Extracting the archive creates a directory named `gawk-4.1.1' in the +Extracting the archive creates a directory named `gawk-4.1.2' in the current directory. The distribution file name is of the form `gawk-V.R.P.tar.gz'. The V represents the major version of `gawk', the R represents the current release of version V, and the P represents a "patch level", meaning that minor bugs have been fixed in the release. The current patch -level is 1, but when retrieving distributions, you should get the +level is 2, but when retrieving distributions, you should get the version with the highest version, release, and patch level. (Note, however, that patch levels greater than or equal to 70 denote "beta" or nonproduction software; you might not want to retrieve such a version @@ -27193,7 +27198,7 @@ Unix-derived systems, GNU/Linux, BSD-based systems, and the Cygwin environment for MS-Windows. After you have extracted the `gawk' distribution, `cd' to -`gawk-4.1.1'. Like most GNU software, `gawk' is configured +`gawk-4.1.2'. Like most GNU software, `gawk' is configured automatically for your system by running the `configure' program. This program is a Bourne shell script that is generated automatically using GNU Autoconf. (The Autoconf software is described fully starting with @@ -27620,8 +27625,8 @@ GNU tools, such as Bash, the GNU Compiler Collection (GCC), GNU Make, and other GNU programs. Compilation and installation for Cygwin is the same as for a Unix system: - tar -xvpzf gawk-4.1.1.tar.gz - cd gawk-4.1.1 + tar -xvpzf gawk-4.1.2.tar.gz + cd gawk-4.1.2 ./configure make @@ -27641,7 +27646,7 @@ use the `BINMODE' variable. This can cause problems with other Unix-like components that have been ported to MS-Windows that expect `gawk' to do automatic -translation of `"\r\n"', since it won't. Caveat Emptor! +translation of `"\r\n"', since it won't. File: gawk.info, Node: VMS Installation, Prev: PC Installation, Up: Non-Unix Installation @@ -28146,9 +28151,9 @@ B.6 Summary * The `gawk' distribution is available from GNU project's main distribution site, `ftp.gnu.org'. The canonical build recipe is: - wget http://ftp.gnu.org/gnu/gawk/gawk-4.1.1.tar.gz - tar -xvpzf gawk-4.1.1.tar.gz - cd gawk-4.1.1 + wget http://ftp.gnu.org/gnu/gawk/gawk-4.1.2.tar.gz + tar -xvpzf gawk-4.1.2.tar.gz + cd gawk-4.1.2 ./configure && make && make check * `gawk' may be built on non-POSIX systems as well. The currently @@ -31026,10 +31031,10 @@ Index * & (ampersand), gsub()/gensub()/sub() functions and: Gory Details. (line 6) * ' (single quote): One-shot. (line 15) -* ' (single quote) in gawk command lines: Long. (line 33) +* ' (single quote) in gawk command lines: Long. (line 35) * ' (single quote), in shell commands: Quoting. (line 48) * ' (single quote), vs. apostrophe: Comments. (line 27) -* ' (single quote), with double quotes: Quoting. (line 70) +* ' (single quote), with double quotes: Quoting. (line 73) * () (parentheses), in a profile: Profiling. (line 146) * () (parentheses), regexp operator: Regexp Operators. (line 81) * * (asterisk), * operator, as multiplication operator: Precedence. @@ -31112,7 +31117,7 @@ Index * -c option: Options. (line 81) * -D option: Options. (line 108) * -d option: Options. (line 93) -* -e option: Options. (line 335) +* -e option: Options. (line 336) * -E option: Options. (line 125) * -e option: Options. (line 117) * -f option: Options. (line 25) @@ -31157,8 +31162,8 @@ Index (line 148) * / (forward slash), patterns and: Expression Patterns. (line 24) * /= operator vs. /=.../ regexp constant: Assignment Ops. (line 148) -* /dev/... special files: Special FD. (line 46) -* /dev/fd/N special files (gawk): Special FD. (line 46) +* /dev/... special files: Special FD. (line 47) +* /dev/fd/N special files (gawk): Special FD. (line 47) * /inet/... special files (gawk): TCP/IP Networking. (line 6) * /inet4/... special files (gawk): TCP/IP Networking. (line 6) * /inet6/... special files (gawk): TCP/IP Networking. (line 6) @@ -31231,7 +31236,7 @@ Index * \ (backslash), \y operator (gawk): GNU Regexp Operators. (line 38) * \ (backslash), as field separator: Command Line Field Separator. - (line 27) + (line 24) * \ (backslash), continuing lines and: Statements/Lines. (line 19) * \ (backslash), continuing lines and, comments and: Statements/Lines. (line 76) @@ -31315,18 +31320,18 @@ Index * arctangent: Numeric Functions. (line 11) * ARGC/ARGV variables: Auto-set. (line 15) * ARGC/ARGV variables, command-line arguments: Other Arguments. - (line 12) + (line 15) * ARGC/ARGV variables, how to use: ARGC and ARGV. (line 6) * ARGC/ARGV variables, portability and: Executable Scripts. (line 59) * ARGIND variable: Auto-set. (line 44) -* ARGIND variable, command-line arguments: Other Arguments. (line 12) +* ARGIND variable, command-line arguments: Other Arguments. (line 15) * arguments, command-line <1>: ARGC and ARGV. (line 6) * arguments, command-line <2>: Auto-set. (line 15) * arguments, command-line: Other Arguments. (line 6) * arguments, command-line, invoking awk: Command Line. (line 6) * arguments, in function calls: Function Calls. (line 18) * arguments, processing: Getopt Function. (line 6) -* ARGV array, indexing into: Other Arguments. (line 12) +* ARGV array, indexing into: Other Arguments. (line 15) * arithmetic operators: Arithmetic Ops. (line 6) * array manipulation in extensions: Array Manipulation. (line 6) * array members: Reference to Elements. @@ -31437,7 +31442,7 @@ Index * awk, gawk and <1>: This Manual. (line 14) * awk, gawk and: Preface. (line 21) * awk, history of: History. (line 17) -* awk, implementation issues, pipes: Redirection. (line 135) +* awk, implementation issues, pipes: Redirection. (line 129) * awk, implementations: Other Versions. (line 6) * awk, implementations, limits: Getline Notes. (line 14) * awk, invoking: Command Line. (line 6) @@ -31501,7 +31506,7 @@ Index * backslash (\), \y operator (gawk): GNU Regexp Operators. (line 38) * backslash (\), as field separator: Command Line Field Separator. - (line 27) + (line 24) * backslash (\), continuing lines and: Statements/Lines. (line 19) * backslash (\), continuing lines and, comments and: Statements/Lines. (line 76) @@ -31698,7 +31703,7 @@ Index * close() function, portability: Close Files And Pipes. (line 81) * close() function, return value: Close Files And Pipes. - (line 131) + (line 132) * close() function, two-way pipes and: Two-way I/O. (line 59) * Close, Diane <1>: Contributors. (line 20) * Close, Diane: Manual History. (line 34) @@ -31734,9 +31739,9 @@ Index * commenting, backslash continuation and: Statements/Lines. (line 76) * common extensions, ** operator: Arithmetic Ops. (line 30) * common extensions, **= operator: Assignment Ops. (line 137) -* common extensions, /dev/stderr special file: Special FD. (line 46) -* common extensions, /dev/stdin special file: Special FD. (line 46) -* common extensions, /dev/stdout special file: Special FD. (line 46) +* common extensions, /dev/stderr special file: Special FD. (line 47) +* common extensions, /dev/stdin special file: Special FD. (line 47) +* common extensions, /dev/stdout special file: Special FD. (line 47) * common extensions, \x escape sequence: Escape Sequences. (line 61) * common extensions, BINMODE variable: PC Using. (line 33) * common extensions, delete to delete entire arrays: Delete. (line 39) @@ -31807,7 +31812,7 @@ Index (line 6) * cookie: Glossary. (line 149) * coprocesses <1>: Two-way I/O. (line 25) -* coprocesses: Redirection. (line 102) +* coprocesses: Redirection. (line 96) * coprocesses, closing: Close Files And Pipes. (line 6) * coprocesses, getline from: Getline/Coprocess. (line 6) @@ -31815,7 +31820,7 @@ Index * cosine: Numeric Functions. (line 15) * counting: Wc Program. (line 6) * csh utility: Statements/Lines. (line 44) -* csh utility, POSIXLY_CORRECT environment variable: Options. (line 353) +* csh utility, POSIXLY_CORRECT environment variable: Options. (line 354) * csh utility, |& operator, comparison with: Two-way I/O. (line 25) * ctime() user-defined function: Function Example. (line 74) * currency symbols, localization: Explaining gettext. (line 104) @@ -31840,11 +31845,11 @@ Index (line 43) * dark corner, break statement: Break Statement. (line 51) * dark corner, close() function: Close Files And Pipes. - (line 131) + (line 132) * dark corner, command-line arguments: Assignment Options. (line 43) * dark corner, continue statement: Continue Statement. (line 44) * dark corner, CONVFMT variable: Strings And Numbers. (line 40) -* dark corner, escape sequences: Other Arguments. (line 35) +* dark corner, escape sequences: Other Arguments. (line 38) * dark corner, escape sequences, for metacharacters: Escape Sequences. (line 140) * dark corner, exit statement: Exit Statement. (line 30) @@ -31856,7 +31861,7 @@ Index * dark corner, format-control characters: Control Letters. (line 18) * dark corner, FS as null string: Single Character Fields. (line 20) -* dark corner, input files: awk split records. (line 110) +* dark corner, input files: awk split records. (line 111) * dark corner, invoking awk: Command Line. (line 16) * dark corner, length() function: String Functions. (line 183) * dark corner, locale's decimal point character: Locale influences conversions. @@ -32050,13 +32055,13 @@ Index * differences in awk and gawk, IGNORECASE variable: User-modified. (line 76) * differences in awk and gawk, implementation limitations <1>: Redirection. - (line 135) + (line 129) * differences in awk and gawk, implementation limitations: Getline Notes. (line 14) * differences in awk and gawk, indirect function calls: Indirect Calls. (line 6) * differences in awk and gawk, input/output operators <1>: Redirection. - (line 102) + (line 96) * differences in awk and gawk, input/output operators: Getline/Coprocess. (line 6) * differences in awk and gawk, line continuations: Conditional Exp. @@ -32069,7 +32074,7 @@ Index * differences in awk and gawk, PROCINFO array: Auto-set. (line 129) * differences in awk and gawk, read timeouts: Read Timeout. (line 6) * differences in awk and gawk, record separators: awk split records. - (line 124) + (line 125) * differences in awk and gawk, regexp constants: Using Constant Regexps. (line 43) * differences in awk and gawk, regular expressions: Case-sensitivity. @@ -32140,7 +32145,7 @@ Index * empty array elements: Reference to Elements. (line 18) * empty pattern: Empty. (line 6) -* empty strings: awk split records. (line 114) +* empty strings: awk split records. (line 115) * empty strings, See null strings: Regexp Field Splitting. (line 43) * enable breakpoint: Breakpoint Control. (line 73) @@ -32182,7 +32187,7 @@ Index * ERRNO variable: Auto-set. (line 74) * ERRNO variable, with BEGINFILE pattern: BEGINFILE/ENDFILE. (line 26) * ERRNO variable, with close() function: Close Files And Pipes. - (line 139) + (line 140) * ERRNO variable, with getline command: Getline. (line 19) * error handling: Special FD. (line 16) * error handling, ERRNO variable and: Auto-set. (line 74) @@ -32251,9 +32256,9 @@ Index * extensions, Brian Kernighan's awk: BTL. (line 6) * extensions, common, ** operator: Arithmetic Ops. (line 30) * extensions, common, **= operator: Assignment Ops. (line 137) -* extensions, common, /dev/stderr special file: Special FD. (line 46) -* extensions, common, /dev/stdin special file: Special FD. (line 46) -* extensions, common, /dev/stdout special file: Special FD. (line 46) +* extensions, common, /dev/stderr special file: Special FD. (line 47) +* extensions, common, /dev/stdin special file: Special FD. (line 47) +* extensions, common, /dev/stdout special file: Special FD. (line 47) * extensions, common, \x escape sequence: Escape Sequences. (line 61) * extensions, common, BINMODE variable: PC Using. (line 33) * extensions, common, delete to delete entire arrays: Delete. (line 39) @@ -32320,7 +32325,7 @@ Index * file inclusion, @include directive: Include Files. (line 8) * file names, distinguishing: Auto-set. (line 56) * file names, in compatibility mode: Special Caveats. (line 9) -* file names, standard streams in gawk: Special FD. (line 46) +* file names, standard streams in gawk: Special FD. (line 47) * FILENAME variable <1>: Auto-set. (line 90) * FILENAME variable: Reading Files. (line 6) * FILENAME variable, getline, setting with: Getline Notes. (line 19) @@ -32333,7 +32338,7 @@ Index * files, .po: Explaining gettext. (line 37) * files, .po, converting to .mo: I18N Example. (line 63) * files, .pot: Explaining gettext. (line 31) -* files, /dev/... special files: Special FD. (line 46) +* files, /dev/... special files: Special FD. (line 47) * files, /inet/... (gawk): TCP/IP Networking. (line 6) * files, /inet4/... (gawk): TCP/IP Networking. (line 6) * files, /inet6/... (gawk): TCP/IP Networking. (line 6) @@ -32356,7 +32361,7 @@ Index (line 47) * files, message object, specifying directory of: Explaining gettext. (line 54) -* files, multiple passes over: Other Arguments. (line 53) +* files, multiple passes over: Other Arguments. (line 56) * files, multiple, duplicating output into: Tee Program. (line 6) * files, output, See output files: Close Files And Pipes. (line 6) @@ -32493,7 +32498,7 @@ Index * Garfinkle, Scott: Contributors. (line 34) * gawk program, dynamic profiling: Profiling. (line 179) * gawk version: Auto-set. (line 206) -* gawk, ARGIND variable in: Other Arguments. (line 12) +* gawk, ARGIND variable in: Other Arguments. (line 15) * gawk, awk and <1>: This Manual. (line 14) * gawk, awk and: Preface. (line 21) * gawk, bitwise operations in: Bitwise Functions. (line 39) @@ -32516,7 +32521,7 @@ Index * gawk, ERRNO variable in <2>: Auto-set. (line 74) * gawk, ERRNO variable in <3>: BEGINFILE/ENDFILE. (line 26) * gawk, ERRNO variable in <4>: Close Files And Pipes. - (line 139) + (line 140) * gawk, ERRNO variable in: Getline. (line 19) * gawk, escape sequences: Escape Sequences. (line 130) * gawk, extensions, disabling: Options. (line 254) @@ -32544,7 +32549,7 @@ Index * gawk, implementation issues, downward compatibility: Compatibility Mode. (line 6) * gawk, implementation issues, limits: Getline Notes. (line 14) -* gawk, implementation issues, pipes: Redirection. (line 135) +* gawk, implementation issues, pipes: Redirection. (line 129) * gawk, installing: Installation. (line 6) * gawk, internationalization and, See internationalization: Internationalization. (line 13) @@ -32571,7 +32576,7 @@ Index * gawk, regular expressions, precedence: Regexp Operators. (line 161) * gawk, RT variable in <1>: Auto-set. (line 264) * gawk, RT variable in <2>: Multiple Line. (line 129) -* gawk, RT variable in: awk split records. (line 124) +* gawk, RT variable in: awk split records. (line 125) * gawk, See Also awk: Preface. (line 34) * gawk, source code, obtaining: Getting. (line 6) * gawk, splitting fields and: Constant Size. (line 88) @@ -32713,7 +32718,7 @@ Index * Illumos, POSIX-compliant awk: Other Versions. (line 105) * implementation issues, gawk: Notes. (line 6) * implementation issues, gawk, debugging: Compatibility Mode. (line 6) -* implementation issues, gawk, limits <1>: Redirection. (line 135) +* implementation issues, gawk, limits <1>: Redirection. (line 129) * implementation issues, gawk, limits: Getline Notes. (line 14) * in operator <1>: For Statement. (line 75) * in operator <2>: Precedence. (line 83) @@ -32744,7 +32749,7 @@ Index * input files, examples: Sample Data Files. (line 6) * input files, reading: Reading Files. (line 6) * input files, running awk without: Read Terminal. (line 6) -* input files, variable assignments and: Other Arguments. (line 23) +* input files, variable assignments and: Other Arguments. (line 26) * input pipeline: Getline/Pipe. (line 9) * input record, length of: String Functions. (line 174) * input redirection: Getline/File. (line 6) @@ -32892,7 +32897,7 @@ Index * lint checking, empty programs: Command Line. (line 16) * lint checking, issuing warnings: Options. (line 185) * lint checking, POSIXLY_CORRECT environment variable: Options. - (line 338) + (line 339) * lint checking, undefined functions: Pass By Value/Reference. (line 88) * LINT variable: User-modified. (line 88) @@ -33036,8 +33041,8 @@ Index * null strings <2>: Truth Values. (line 6) * null strings <3>: Regexp Field Splitting. (line 43) -* null strings: awk split records. (line 114) -* null strings in gawk arguments, quoting and: Quoting. (line 79) +* null strings: awk split records. (line 115) +* null strings in gawk arguments, quoting and: Quoting. (line 82) * null strings, and deleting array elements: Delete. (line 27) * null strings, as array subscripts: Uninitialized Subscripts. (line 43) @@ -33212,7 +33217,7 @@ Index * portability, NF variable, decrementing: Changing Fields. (line 115) * portability, operators: Increment Ops. (line 60) * portability, operators, not in POSIX awk: Precedence. (line 98) -* portability, POSIXLY_CORRECT environment variable: Options. (line 358) +* portability, POSIXLY_CORRECT environment variable: Options. (line 359) * portability, substr() function: String Functions. (line 510) * portable object files <1>: Translator i18n. (line 6) * portable object files: Explaining gettext. (line 37) @@ -33257,7 +33262,7 @@ Index * 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, printf format strings and: Format Modifiers. (line 158) * POSIX awk, regular expressions and: Regexp Operators. (line 161) * POSIX awk, timestamps and: Time Functions. (line 6) * POSIX awk, | I/O operator and: Getline/Pipe. (line 55) @@ -33265,7 +33270,7 @@ Index * POSIX, awk and: Preface. (line 21) * POSIX, gawk extensions not included in: POSIX/GNU. (line 6) * POSIX, programs, implementing in awk: Clones. (line 6) -* POSIXLY_CORRECT environment variable: Options. (line 338) +* POSIXLY_CORRECT environment variable: Options. (line 339) * PREC variable: User-modified. (line 124) * precedence <1>: Precedence. (line 6) * precedence: Increment Ops. (line 60) @@ -33362,7 +33367,7 @@ Index (line 99) * QUIT signal (MS-Windows): Profiling. (line 214) * quoting in gawk command lines: Long. (line 26) -* quoting in gawk command lines, tricks for: Quoting. (line 88) +* quoting in gawk command lines, tricks for: Quoting. (line 91) * quoting, for small awk programs: Comments. (line 27) * r debugger command (alias for run): Debugger Execution Control. (line 62) @@ -33397,15 +33402,15 @@ Index * record separators: awk split records. (line 6) * record separators, changing: awk split records. (line 85) * record separators, regular expressions as: awk split records. - (line 124) + (line 125) * record separators, with multiline records: Multiple Line. (line 10) * records <1>: Basic High Level. (line 73) * records: Reading Files. (line 14) * records, multiline: Multiple Line. (line 6) * records, printing: Print. (line 22) * records, splitting input into: Records. (line 6) -* records, terminating: awk split records. (line 124) -* records, treating files as: gawk split records. (line 92) +* records, terminating: awk split records. (line 125) +* records, treating files as: gawk split records. (line 93) * recursive functions: Definition Syntax. (line 83) * redirect gawk output, in debugger: Debugger Info. (line 72) * redirection of input: Getline/File. (line 6) @@ -33433,7 +33438,7 @@ Index * regular expressions, as patterns <1>: Regexp Patterns. (line 6) * regular expressions, as patterns: Regexp Usage. (line 6) * regular expressions, as record separators: awk split records. - (line 124) + (line 125) * regular expressions, case sensitivity <1>: User-modified. (line 76) * regular expressions, case sensitivity: Case-sensitivity. (line 6) * regular expressions, computed: Computed Regexps. (line 6) @@ -33465,7 +33470,7 @@ Index (line 54) * return statement, user-defined functions: Return Statement. (line 6) * return value, close() function: Close Files And Pipes. - (line 131) + (line 132) * rev() user-defined function: Function Example. (line 54) * revoutput extension: Extension Sample Revout. (line 11) @@ -33494,7 +33499,7 @@ Index * Robbins, Arnold <6>: Passwd Functions. (line 90) * Robbins, Arnold <7>: Getline/Pipe. (line 39) * Robbins, Arnold: Command Line Field Separator. - (line 74) + (line 71) * Robbins, Bill: Getline/Pipe. (line 39) * Robbins, Harry: Acknowledgments. (line 92) * Robbins, Jean: Acknowledgments. (line 92) @@ -33514,7 +33519,7 @@ Index * RSTART variable, match() function and: String Functions. (line 224) * RT variable <1>: Auto-set. (line 264) * RT variable <2>: Multiple Line. (line 129) -* RT variable: awk split records. (line 124) +* RT variable: awk split records. (line 125) * Rubin, Paul <1>: Contributors. (line 15) * Rubin, Paul: History. (line 30) * rule, definition of: Getting Started. (line 21) @@ -33567,7 +33572,7 @@ Index * separators, for records <1>: User-modified. (line 133) * separators, for records: awk split records. (line 6) * separators, for records, regular expressions as: awk split records. - (line 124) + (line 125) * separators, for statements in actions: Action Overview. (line 19) * separators, subscript: User-modified. (line 146) * set breakpoint: Breakpoint Control. (line 11) @@ -33578,7 +33583,7 @@ Index (line 67) * shadowing of variable values: Definition Syntax. (line 71) * shell quoting, rules for: Quoting. (line 6) -* shells, piping commands into: Redirection. (line 142) +* shells, piping commands into: Redirection. (line 136) * shells, quoting: Using Shell Variables. (line 12) * shells, quoting, rules for: Quoting. (line 18) @@ -33627,7 +33632,7 @@ Index (line 107) * sidebar, Matching the Null String: Gory Details. (line 141) * sidebar, Operator Evaluation Order: Increment Ops. (line 58) -* sidebar, Piping into sh: Redirection. (line 140) +* sidebar, Piping into sh: Redirection. (line 134) * sidebar, Pre-POSIX awk Used OFMT For String Conversion: Strings And Numbers. (line 55) * sidebar, Recipe For A Programming Language: History. (line 6) @@ -33641,7 +33646,7 @@ Index * sidebar, Using \n in Bracket Expressions of Dynamic Regexps: Computed Regexps. (line 57) * sidebar, Using close()'s Return Value: Close Files And Pipes. - (line 129) + (line 130) * SIGHUP signal, for dynamic profiling: Profiling. (line 211) * SIGINT signal (MS-Windows): Profiling. (line 214) * signals, HUP/SIGHUP, for profiling: Profiling. (line 211) @@ -33656,10 +33661,10 @@ Index * sin: Numeric Functions. (line 76) * sine: Numeric Functions. (line 76) * single quote ('): One-shot. (line 15) -* single quote (') in gawk command lines: Long. (line 33) +* single quote (') in gawk command lines: Long. (line 35) * single quote ('), in shell commands: Quoting. (line 48) * single quote ('), vs. apostrophe: Comments. (line 27) -* single quote ('), with double quotes: Quoting. (line 70) +* single quote ('), with double quotes: Quoting. (line 73) * single-character fields: Single Character Fields. (line 6) * single-step execution, in the debugger: Debugger Execution Control. @@ -33748,7 +33753,7 @@ Index * strings, converting: Strings And Numbers. (line 6) * strings, converting letter case: String Functions. (line 520) * strings, converting, numbers to: User-modified. (line 30) -* strings, empty, See null strings: awk split records. (line 114) +* strings, empty, See null strings: awk split records. (line 115) * strings, extracting: String Extraction. (line 6) * strings, for localization: Programmer i18n. (line 14) * strings, length limitations: Scalar Constants. (line 20) @@ -33794,7 +33799,7 @@ Index * tee utility: Tee Program. (line 6) * tee.awk program: Tee Program. (line 26) * temporary breakpoint: Breakpoint Control. (line 90) -* terminating records: awk split records. (line 124) +* terminating records: awk split records. (line 125) * testbits.awk program: Bitwise Functions. (line 70) * testext extension: Extension Sample API Tests. (line 6) @@ -33842,7 +33847,7 @@ Index * traceback, display in debugger: Execution Stack. (line 13) * translate string: I18N Functions. (line 22) * translate.awk program: Translate Program. (line 55) -* treating files, as single records: gawk split records. (line 92) +* treating files, as single records: gawk split records. (line 93) * troubleshooting, --non-decimal-data option: Options. (line 211) * troubleshooting, == operator: Comparison Operators. (line 37) @@ -33853,7 +33858,7 @@ Index * troubleshooting, fatal errors, field widths, specifying: Constant Size. (line 23) * troubleshooting, fatal errors, printf format strings: Format Modifiers. - (line 159) + (line 158) * troubleshooting, fflush() function: I/O Functions. (line 63) * troubleshooting, function call syntax: Function Calls. (line 30) * troubleshooting, gawk: Compatibility Mode. (line 6) @@ -33865,8 +33870,8 @@ Index * troubleshooting, match() function: String Functions. (line 289) * troubleshooting, print statement, omitting commas: Print Examples. (line 31) -* troubleshooting, printing: Redirection. (line 118) -* troubleshooting, quotes with file names: Special FD. (line 68) +* troubleshooting, printing: Redirection. (line 112) +* troubleshooting, quotes with file names: Special FD. (line 69) * troubleshooting, readable data files: File Checking. (line 6) * troubleshooting, regexp constants vs. string constants: Computed Regexps. (line 39) @@ -33906,9 +33911,9 @@ Index * Unix awk, backslashes in escape sequences: Escape Sequences. (line 130) * Unix awk, close() function and: Close Files And Pipes. - (line 131) + (line 132) * Unix awk, password files, field separators and: Command Line Field Separator. - (line 65) + (line 62) * Unix, awk scripts and: Executable Scripts. (line 6) * UNIXROOT variable, on OS/2 systems: PC Using. (line 16) * unsigned integers: Computer Arithmetic. (line 41) @@ -33927,7 +33932,7 @@ Index * USR1 signal, for dynamic profiling: Profiling. (line 188) * values, numeric: Basic Data Typing. (line 13) * values, string: Basic Data Typing. (line 13) -* variable assignments and input files: Other Arguments. (line 23) +* variable assignments and input files: Other Arguments. (line 26) * variable typing: Typing and Comparison. (line 9) * variables <1>: Basic Data Typing. (line 6) @@ -34030,10 +34035,10 @@ Index * | (vertical bar), | operator (I/O): Getline/Pipe. (line 9) * | (vertical bar), |& operator (I/O) <1>: Two-way I/O. (line 25) * | (vertical bar), |& operator (I/O) <2>: Precedence. (line 65) -* | (vertical bar), |& operator (I/O) <3>: Redirection. (line 102) +* | (vertical bar), |& operator (I/O) <3>: Redirection. (line 96) * | (vertical bar), |& operator (I/O): Getline/Coprocess. (line 6) * | (vertical bar), |& operator (I/O), pipes, closing: Close Files And Pipes. - (line 119) + (line 120) * | (vertical bar), || operator <1>: Precedence. (line 89) * | (vertical bar), || operator: Boolean Ops. (line 57) * ~ (tilde), ~ operator <1>: Expression Patterns. (line 24) @@ -34050,552 +34055,552 @@ Index Tag Table: Node: Top1204 Node: Foreword41858 -Node: Preface46203 -Ref: Preface-Footnote-149226 -Ref: Preface-Footnote-249333 -Node: History49565 -Node: Names51939 -Ref: Names-Footnote-153033 -Node: This Manual53179 -Ref: This Manual-Footnote-158958 -Node: Conventions59058 -Node: Manual History61403 -Ref: Manual History-Footnote-164479 -Ref: Manual History-Footnote-264520 -Node: How To Contribute64594 -Node: Acknowledgments65833 -Node: Getting Started70581 -Node: Running gawk73015 -Node: One-shot74205 -Node: Read Terminal75430 -Node: Long77455 -Node: Executable Scripts78849 -Ref: Executable Scripts-Footnote-181650 -Node: Comments81752 -Node: Quoting84225 -Node: DOS Quoting89538 -Node: Sample Data Files90213 -Node: Very Simple92820 -Node: Two Rules97705 -Node: More Complex99599 -Ref: More Complex-Footnote-1102513 -Node: Statements/Lines102598 -Ref: Statements/Lines-Footnote-1107054 -Node: Other Features107319 -Node: When108250 -Ref: When-Footnote-1110006 -Node: Intro Summary110071 -Node: Invoking Gawk110954 -Node: Command Line112469 -Node: Options113260 -Ref: Options-Footnote-1129036 -Node: Other Arguments129061 -Node: Naming Standard Input131889 -Node: Environment Variables132982 -Node: AWKPATH Variable133540 -Ref: AWKPATH Variable-Footnote-1136406 -Ref: AWKPATH Variable-Footnote-2136451 -Node: AWKLIBPATH Variable136711 -Node: Other Environment Variables137470 -Node: Exit Status141127 -Node: Include Files141802 -Node: Loading Shared Libraries145380 -Node: Obsolete146764 -Node: Undocumented147461 -Node: Invoking Summary147728 -Node: Regexp149328 -Node: Regexp Usage150787 -Node: Escape Sequences152820 -Node: Regexp Operators158808 -Ref: Regexp Operators-Footnote-1166239 -Ref: Regexp Operators-Footnote-2166386 -Node: Bracket Expressions166484 -Ref: table-char-classes168502 -Node: Leftmost Longest171442 -Node: Computed Regexps172646 -Node: GNU Regexp Operators176024 -Node: Case-sensitivity179730 -Ref: Case-sensitivity-Footnote-1182620 -Ref: Case-sensitivity-Footnote-2182855 -Node: Regexp Summary182963 -Node: Reading Files184432 -Node: Records186524 -Node: awk split records187246 -Node: gawk split records192104 -Ref: gawk split records-Footnote-1196625 -Node: Fields196662 -Ref: Fields-Footnote-1199626 -Node: Nonconstant Fields199712 -Ref: Nonconstant Fields-Footnote-1201942 -Node: Changing Fields202144 -Node: Field Separators208098 -Node: Default Field Splitting210800 -Node: Regexp Field Splitting211917 -Node: Single Character Fields215244 -Node: Command Line Field Separator216303 -Node: Full Line Fields219729 -Ref: Full Line Fields-Footnote-1220237 -Node: Field Splitting Summary220283 -Ref: Field Splitting Summary-Footnote-1223415 -Node: Constant Size223516 -Node: Splitting By Content228122 -Ref: Splitting By Content-Footnote-1232195 -Node: Multiple Line232235 -Ref: Multiple Line-Footnote-1238091 -Node: Getline238270 -Node: Plain Getline240481 -Node: Getline/Variable243187 -Node: Getline/File244334 -Node: Getline/Variable/File245718 -Ref: Getline/Variable/File-Footnote-1247317 -Node: Getline/Pipe247404 -Node: Getline/Variable/Pipe250090 -Node: Getline/Coprocess251197 -Node: Getline/Variable/Coprocess252449 -Node: Getline Notes253186 -Node: Getline Summary255990 -Ref: table-getline-variants256398 -Node: Read Timeout257310 -Ref: Read Timeout-Footnote-1261137 -Node: Command-line directories261195 -Node: Input Summary262099 -Node: Input Exercises265236 -Node: Printing265964 -Node: Print267686 -Node: Print Examples269179 -Node: Output Separators271958 -Node: OFMT273974 -Node: Printf275332 -Node: Basic Printf276238 -Node: Control Letters277777 -Node: Format Modifiers281768 -Node: Printf Examples287795 -Node: Redirection290259 -Node: Special Files297231 -Node: Special FD297764 -Ref: Special FD-Footnote-1301361 -Node: Special Network301435 -Node: Special Caveats302285 -Node: Close Files And Pipes303081 -Ref: Close Files And Pipes-Footnote-1310242 -Ref: Close Files And Pipes-Footnote-2310390 -Node: Output Summary310540 -Node: Output Exercises311537 -Node: Expressions312217 -Node: Values313402 -Node: Constants314078 -Node: Scalar Constants314758 -Ref: Scalar Constants-Footnote-1315617 -Node: Nondecimal-numbers315867 -Node: Regexp Constants318867 -Node: Using Constant Regexps319392 -Node: Variables322464 -Node: Using Variables323119 -Node: Assignment Options325025 -Node: Conversion326900 -Node: Strings And Numbers327424 -Ref: Strings And Numbers-Footnote-1330486 -Node: Locale influences conversions330595 -Ref: table-locale-affects333312 -Node: All Operators333900 -Node: Arithmetic Ops334530 -Node: Concatenation337035 -Ref: Concatenation-Footnote-1339854 -Node: Assignment Ops339960 -Ref: table-assign-ops344943 -Node: Increment Ops346246 -Node: Truth Values and Conditions349684 -Node: Truth Values350767 -Node: Typing and Comparison351816 -Node: Variable Typing352609 -Node: Comparison Operators356261 -Ref: table-relational-ops356671 -Node: POSIX String Comparison360221 -Ref: POSIX String Comparison-Footnote-1361305 -Node: Boolean Ops361443 -Ref: Boolean Ops-Footnote-1365782 -Node: Conditional Exp365873 -Node: Function Calls367600 -Node: Precedence371480 -Node: Locales375149 -Node: Expressions Summary376780 -Node: Patterns and Actions379321 -Node: Pattern Overview380437 -Node: Regexp Patterns382114 -Node: Expression Patterns382657 -Node: Ranges386437 -Node: BEGIN/END389543 -Node: Using BEGIN/END390305 -Ref: Using BEGIN/END-Footnote-1393041 -Node: I/O And BEGIN/END393147 -Node: BEGINFILE/ENDFILE395418 -Node: Empty398349 -Node: Using Shell Variables398666 -Node: Action Overview400949 -Node: Statements403276 -Node: If Statement405124 -Node: While Statement406622 -Node: Do Statement408666 -Node: For Statement409822 -Node: Switch Statement412974 -Node: Break Statement415362 -Node: Continue Statement417403 -Node: Next Statement419228 -Node: Nextfile Statement421598 -Node: Exit Statement424255 -Node: Built-in Variables426659 -Node: User-modified427786 -Ref: User-modified-Footnote-1435475 -Node: Auto-set435537 -Ref: Auto-set-Footnote-1448389 -Ref: Auto-set-Footnote-2448594 -Node: ARGC and ARGV448650 -Node: Pattern Action Summary452554 -Node: Arrays454777 -Node: Array Basics456326 -Node: Array Intro457152 -Ref: figure-array-elements459125 -Ref: Array Intro-Footnote-1461649 -Node: Reference to Elements461777 -Node: Assigning Elements464227 -Node: Array Example464718 -Node: Scanning an Array466450 -Node: Controlling Scanning469451 -Ref: Controlling Scanning-Footnote-1474624 -Node: Delete474940 -Ref: Delete-Footnote-1477691 -Node: Numeric Array Subscripts477748 -Node: Uninitialized Subscripts479931 -Node: Multidimensional481558 -Node: Multiscanning484671 -Node: Arrays of Arrays486260 -Node: Arrays Summary490923 -Node: Functions493028 -Node: Built-in493901 -Node: Calling Built-in494979 -Node: Numeric Functions496967 -Ref: Numeric Functions-Footnote-1501001 -Ref: Numeric Functions-Footnote-2501358 -Ref: Numeric Functions-Footnote-3501406 -Node: String Functions501675 -Ref: String Functions-Footnote-1524672 -Ref: String Functions-Footnote-2524801 -Ref: String Functions-Footnote-3525049 -Node: Gory Details525136 -Ref: table-sub-escapes526909 -Ref: table-sub-proposed528429 -Ref: table-posix-sub529793 -Ref: table-gensub-escapes531333 -Ref: Gory Details-Footnote-1532509 -Node: I/O Functions532660 -Ref: I/O Functions-Footnote-1539770 -Node: Time Functions539917 -Ref: Time Functions-Footnote-1550381 -Ref: Time Functions-Footnote-2550449 -Ref: Time Functions-Footnote-3550607 -Ref: Time Functions-Footnote-4550718 -Ref: Time Functions-Footnote-5550830 -Ref: Time Functions-Footnote-6551057 -Node: Bitwise Functions551323 -Ref: table-bitwise-ops551885 -Ref: Bitwise Functions-Footnote-1556130 -Node: Type Functions556314 -Node: I18N Functions557456 -Node: User-defined559101 -Node: Definition Syntax559905 -Ref: Definition Syntax-Footnote-1565309 -Node: Function Example565378 -Ref: Function Example-Footnote-1568018 -Node: Function Caveats568040 -Node: Calling A Function568558 -Node: Variable Scope569513 -Node: Pass By Value/Reference572501 -Node: Return Statement576011 -Node: Dynamic Typing578995 -Node: Indirect Calls579924 -Ref: Indirect Calls-Footnote-1589640 -Node: Functions Summary589768 -Node: Library Functions592418 -Ref: Library Functions-Footnote-1596036 -Ref: Library Functions-Footnote-2596179 -Node: Library Names596350 -Ref: Library Names-Footnote-1599823 -Ref: Library Names-Footnote-2600043 -Node: General Functions600129 -Node: Strtonum Function601157 -Node: Assert Function604059 -Node: Round Function607385 -Node: Cliff Random Function608926 -Node: Ordinal Functions609942 -Ref: Ordinal Functions-Footnote-1613007 -Ref: Ordinal Functions-Footnote-2613259 -Node: Join Function613470 -Ref: Join Function-Footnote-1615241 -Node: Getlocaltime Function615441 -Node: Readfile Function619177 -Node: Data File Management621016 -Node: Filetrans Function621648 -Node: Rewind Function625717 -Node: File Checking627275 -Ref: File Checking-Footnote-1628407 -Node: Empty Files628608 -Node: Ignoring Assigns630587 -Node: Getopt Function632141 -Ref: Getopt Function-Footnote-1643405 -Node: Passwd Functions643608 -Ref: Passwd Functions-Footnote-1652587 -Node: Group Functions652675 -Ref: Group Functions-Footnote-1660606 -Node: Walking Arrays660819 -Node: Library Functions Summary662422 -Node: Library Exercises663810 -Node: Sample Programs665090 -Node: Running Examples665860 -Node: Clones666588 -Node: Cut Program667812 -Node: Egrep Program677670 -Ref: Egrep Program-Footnote-1685257 -Node: Id Program685367 -Node: Split Program689021 -Ref: Split Program-Footnote-1692559 -Node: Tee Program692687 -Node: Uniq Program695474 -Node: Wc Program702897 -Ref: Wc Program-Footnote-1707162 -Node: Miscellaneous Programs707254 -Node: Dupword Program708467 -Node: Alarm Program710498 -Node: Translate Program715302 -Ref: Translate Program-Footnote-1719875 -Ref: Translate Program-Footnote-2720145 -Node: Labels Program720284 -Ref: Labels Program-Footnote-1723645 -Node: Word Sorting723729 -Node: History Sorting727772 -Node: Extract Program729608 -Node: Simple Sed737144 -Node: Igawk Program740206 -Ref: Igawk Program-Footnote-1754510 -Ref: Igawk Program-Footnote-2754711 -Node: Anagram Program754849 -Node: Signature Program757917 -Node: Programs Summary759164 -Node: Programs Exercises760379 -Ref: Programs Exercises-Footnote-1764510 -Node: Advanced Features764601 -Node: Nondecimal Data766549 -Node: Array Sorting768126 -Node: Controlling Array Traversal768823 -Node: Array Sorting Functions777103 -Ref: Array Sorting Functions-Footnote-1781010 -Node: Two-way I/O781204 -Ref: Two-way I/O-Footnote-1786148 -Ref: Two-way I/O-Footnote-2786327 -Node: TCP/IP Networking786409 -Node: Profiling789251 -Node: Advanced Features Summary796793 -Node: Internationalization798657 -Node: I18N and L10N800137 -Node: Explaining gettext800823 -Ref: Explaining gettext-Footnote-1805849 -Ref: Explaining gettext-Footnote-2806033 -Node: Programmer i18n806198 -Ref: Programmer i18n-Footnote-1810992 -Node: Translator i18n811041 -Node: String Extraction811835 -Ref: String Extraction-Footnote-1812968 -Node: Printf Ordering813054 -Ref: Printf Ordering-Footnote-1815836 -Node: I18N Portability815900 -Ref: I18N Portability-Footnote-1818349 -Node: I18N Example818412 -Ref: I18N Example-Footnote-1821118 -Node: Gawk I18N821190 -Node: I18N Summary821828 -Node: Debugger823167 -Node: Debugging824189 -Node: Debugging Concepts824630 -Node: Debugging Terms826486 -Node: Awk Debugging829083 -Node: Sample Debugging Session829975 -Node: Debugger Invocation830495 -Node: Finding The Bug831831 -Node: List of Debugger Commands838310 -Node: Breakpoint Control839642 -Node: Debugger Execution Control843306 -Node: Viewing And Changing Data846666 -Node: Execution Stack850024 -Node: Debugger Info851537 -Node: Miscellaneous Debugger Commands855531 -Node: Readline Support860715 -Node: Limitations861607 -Node: Debugging Summary863880 -Node: Arbitrary Precision Arithmetic865048 -Node: Computer Arithmetic866535 -Ref: Computer Arithmetic-Footnote-1870922 -Node: Math Definitions870979 -Ref: table-ieee-formats874268 -Ref: Math Definitions-Footnote-1874808 -Node: MPFR features874911 -Node: FP Math Caution876528 -Ref: FP Math Caution-Footnote-1877578 -Node: Inexactness of computations877947 -Node: Inexact representation878895 -Node: Comparing FP Values880250 -Node: Errors accumulate881214 -Node: Getting Accuracy882647 -Node: Try To Round885306 -Node: Setting precision886205 -Ref: table-predefined-precision-strings886887 -Node: Setting the rounding mode888680 -Ref: table-gawk-rounding-modes889044 -Ref: Setting the rounding mode-Footnote-1892498 -Node: Arbitrary Precision Integers892677 -Ref: Arbitrary Precision Integers-Footnote-1895658 -Node: POSIX Floating Point Problems895807 -Ref: POSIX Floating Point Problems-Footnote-1899683 -Node: Floating point summary899721 -Node: Dynamic Extensions901925 -Node: Extension Intro903477 -Node: Plugin License904742 -Node: Extension Mechanism Outline905427 -Ref: figure-load-extension905851 -Ref: figure-load-new-function907336 -Ref: figure-call-new-function908338 -Node: Extension API Description910322 -Node: Extension API Functions Introduction911772 -Node: General Data Types916639 -Ref: General Data Types-Footnote-1922332 -Node: Requesting Values922631 -Ref: table-value-types-returned923368 -Node: Memory Allocation Functions924326 -Ref: Memory Allocation Functions-Footnote-1927073 -Node: Constructor Functions927169 -Node: Registration Functions928927 -Node: Extension Functions929612 -Node: Exit Callback Functions931914 -Node: Extension Version String933162 -Node: Input Parsers933812 -Node: Output Wrappers943626 -Node: Two-way processors948142 -Node: Printing Messages950346 -Ref: Printing Messages-Footnote-1951423 -Node: Updating `ERRNO'951575 -Node: Accessing Parameters952314 -Node: Symbol Table Access953544 -Node: Symbol table by name954058 -Node: Symbol table by cookie956034 -Ref: Symbol table by cookie-Footnote-1960167 -Node: Cached values960230 -Ref: Cached values-Footnote-1963734 -Node: Array Manipulation963825 -Ref: Array Manipulation-Footnote-1964923 -Node: Array Data Types964962 -Ref: Array Data Types-Footnote-1967665 -Node: Array Functions967757 -Node: Flattening Arrays971631 -Node: Creating Arrays978483 -Node: Extension API Variables983214 -Node: Extension Versioning983850 -Node: Extension API Informational Variables985751 -Node: Extension API Boilerplate986837 -Node: Finding Extensions990641 -Node: Extension Example991201 -Node: Internal File Description991931 -Node: Internal File Ops996022 -Ref: Internal File Ops-Footnote-11007454 -Node: Using Internal File Ops1007594 -Ref: Using Internal File Ops-Footnote-11009941 -Node: Extension Samples1010209 -Node: Extension Sample File Functions1011733 -Node: Extension Sample Fnmatch1019301 -Node: Extension Sample Fork1020783 -Node: Extension Sample Inplace1021996 -Node: Extension Sample Ord1023671 -Node: Extension Sample Readdir1024507 -Ref: table-readdir-file-types1025363 -Node: Extension Sample Revout1026162 -Node: Extension Sample Rev2way1026753 -Node: Extension Sample Read write array1027494 -Node: Extension Sample Readfile1029373 -Node: Extension Sample API Tests1030473 -Node: Extension Sample Time1030998 -Node: gawkextlib1032313 -Node: Extension summary1035126 -Node: Extension Exercises1038819 -Node: Language History1039541 -Node: V7/SVR3.11041184 -Node: SVR41043504 -Node: POSIX1044946 -Node: BTL1046332 -Node: POSIX/GNU1047066 -Node: Feature History1052782 -Node: Common Extensions1065873 -Node: Ranges and Locales1067185 -Ref: Ranges and Locales-Footnote-11071802 -Ref: Ranges and Locales-Footnote-21071829 -Ref: Ranges and Locales-Footnote-31072063 -Node: Contributors1072284 -Node: History summary1077709 -Node: Installation1079078 -Node: Gawk Distribution1080029 -Node: Getting1080513 -Node: Extracting1081337 -Node: Distribution contents1082979 -Node: Unix Installation1088696 -Node: Quick Installation1089313 -Node: Additional Configuration Options1091755 -Node: Configuration Philosophy1093493 -Node: Non-Unix Installation1095844 -Node: PC Installation1096302 -Node: PC Binary Installation1097613 -Node: PC Compiling1099461 -Ref: PC Compiling-Footnote-11102460 -Node: PC Testing1102565 -Node: PC Using1103741 -Node: Cygwin1107893 -Node: MSYS1108702 -Node: VMS Installation1109216 -Node: VMS Compilation1110012 -Ref: VMS Compilation-Footnote-11111234 -Node: VMS Dynamic Extensions1111292 -Node: VMS Installation Details1112665 -Node: VMS Running1114917 -Node: VMS GNV1117751 -Node: VMS Old Gawk1118474 -Node: Bugs1118944 -Node: Other Versions1122948 -Node: Installation summary1129172 -Node: Notes1130228 -Node: Compatibility Mode1131093 -Node: Additions1131875 -Node: Accessing The Source1132800 -Node: Adding Code1134236 -Node: New Ports1140414 -Node: Derived Files1144895 -Ref: Derived Files-Footnote-11150370 -Ref: Derived Files-Footnote-21150404 -Ref: Derived Files-Footnote-31151000 -Node: Future Extensions1151114 -Node: Implementation Limitations1151720 -Node: Extension Design1152968 -Node: Old Extension Problems1154122 -Ref: Old Extension Problems-Footnote-11155639 -Node: Extension New Mechanism Goals1155696 -Ref: Extension New Mechanism Goals-Footnote-11159056 -Node: Extension Other Design Decisions1159245 -Node: Extension Future Growth1161351 -Node: Old Extension Mechanism1162187 -Node: Notes summary1163949 -Node: Basic Concepts1165135 -Node: Basic High Level1165816 -Ref: figure-general-flow1166088 -Ref: figure-process-flow1166687 -Ref: Basic High Level-Footnote-11169916 -Node: Basic Data Typing1170101 -Node: Glossary1173429 -Node: Copying1198581 -Node: GNU Free Documentation License1236137 -Node: Index1261273 +Node: Preface46205 +Ref: Preface-Footnote-149100 +Ref: Preface-Footnote-249207 +Ref: Preface-Footnote-349440 +Node: History49582 +Node: Names51956 +Ref: Names-Footnote-153050 +Node: This Manual53196 +Ref: This Manual-Footnote-159031 +Node: Conventions59131 +Node: Manual History61476 +Ref: Manual History-Footnote-164552 +Ref: Manual History-Footnote-264593 +Node: How To Contribute64667 +Node: Acknowledgments65906 +Node: Getting Started70654 +Node: Running gawk73088 +Node: One-shot74278 +Node: Read Terminal75503 +Node: Long77530 +Node: Executable Scripts79046 +Ref: Executable Scripts-Footnote-181835 +Node: Comments81937 +Node: Quoting84410 +Node: DOS Quoting89920 +Node: Sample Data Files90595 +Node: Very Simple93188 +Node: Two Rules98079 +Node: More Complex99965 +Node: Statements/Lines102827 +Ref: Statements/Lines-Footnote-1107283 +Node: Other Features107548 +Node: When108479 +Ref: When-Footnote-1110235 +Node: Intro Summary110300 +Node: Invoking Gawk111183 +Node: Command Line112698 +Node: Options113489 +Ref: Options-Footnote-1129316 +Node: Other Arguments129341 +Node: Naming Standard Input132302 +Node: Environment Variables133395 +Node: AWKPATH Variable133953 +Ref: AWKPATH Variable-Footnote-1136805 +Ref: AWKPATH Variable-Footnote-2136850 +Node: AWKLIBPATH Variable137110 +Node: Other Environment Variables137869 +Node: Exit Status141571 +Node: Include Files142246 +Node: Loading Shared Libraries145824 +Node: Obsolete147251 +Node: Undocumented147948 +Node: Invoking Summary148215 +Node: Regexp149881 +Node: Regexp Usage151340 +Node: Escape Sequences153373 +Node: Regexp Operators159390 +Ref: Regexp Operators-Footnote-1166825 +Ref: Regexp Operators-Footnote-2166972 +Node: Bracket Expressions167070 +Ref: table-char-classes169087 +Node: Leftmost Longest172027 +Node: Computed Regexps173329 +Node: GNU Regexp Operators176726 +Node: Case-sensitivity180432 +Ref: Case-sensitivity-Footnote-1183322 +Ref: Case-sensitivity-Footnote-2183557 +Node: Regexp Summary183665 +Node: Reading Files185134 +Node: Records187226 +Node: awk split records187954 +Node: gawk split records192866 +Ref: gawk split records-Footnote-1197405 +Node: Fields197442 +Ref: Fields-Footnote-1200238 +Node: Nonconstant Fields200324 +Ref: Nonconstant Fields-Footnote-1202554 +Node: Changing Fields202756 +Node: Field Separators208688 +Node: Default Field Splitting211390 +Node: Regexp Field Splitting212507 +Node: Single Character Fields215857 +Node: Command Line Field Separator216916 +Node: Full Line Fields220126 +Ref: Full Line Fields-Footnote-1220634 +Node: Field Splitting Summary220680 +Ref: Field Splitting Summary-Footnote-1223811 +Node: Constant Size223912 +Node: Splitting By Content228518 +Ref: Splitting By Content-Footnote-1232591 +Node: Multiple Line232631 +Ref: Multiple Line-Footnote-1238520 +Node: Getline238699 +Node: Plain Getline240910 +Node: Getline/Variable243550 +Node: Getline/File244697 +Node: Getline/Variable/File246081 +Ref: Getline/Variable/File-Footnote-1247680 +Node: Getline/Pipe247767 +Node: Getline/Variable/Pipe250450 +Node: Getline/Coprocess251579 +Node: Getline/Variable/Coprocess252831 +Node: Getline Notes253568 +Node: Getline Summary256360 +Ref: table-getline-variants256768 +Node: Read Timeout257597 +Ref: Read Timeout-Footnote-1261411 +Node: Command-line directories261469 +Node: Input Summary262373 +Node: Input Exercises265625 +Node: Printing266353 +Node: Print268075 +Node: Print Examples269532 +Node: Output Separators272311 +Node: OFMT274327 +Node: Printf275679 +Node: Basic Printf276464 +Node: Control Letters278035 +Node: Format Modifiers282019 +Node: Printf Examples288026 +Node: Redirection290508 +Node: Special Files297242 +Node: Special FD297775 +Ref: Special FD-Footnote-1301469 +Node: Special Network301543 +Node: Special Caveats302393 +Node: Close Files And Pipes303185 +Ref: Close Files And Pipes-Footnote-1310362 +Ref: Close Files And Pipes-Footnote-2310510 +Node: Output Summary310660 +Node: Output Exercises311654 +Node: Expressions312334 +Node: Values313519 +Node: Constants314195 +Node: Scalar Constants314875 +Ref: Scalar Constants-Footnote-1315734 +Node: Nondecimal-numbers315984 +Node: Regexp Constants318984 +Node: Using Constant Regexps319509 +Node: Variables322581 +Node: Using Variables323236 +Node: Assignment Options325142 +Node: Conversion327017 +Node: Strings And Numbers327541 +Ref: Strings And Numbers-Footnote-1330603 +Node: Locale influences conversions330712 +Ref: table-locale-affects333429 +Node: All Operators334017 +Node: Arithmetic Ops334647 +Node: Concatenation337152 +Ref: Concatenation-Footnote-1339971 +Node: Assignment Ops340077 +Ref: table-assign-ops345060 +Node: Increment Ops346363 +Node: Truth Values and Conditions349801 +Node: Truth Values350884 +Node: Typing and Comparison351933 +Node: Variable Typing352726 +Node: Comparison Operators356378 +Ref: table-relational-ops356788 +Node: POSIX String Comparison360337 +Ref: POSIX String Comparison-Footnote-1361421 +Node: Boolean Ops361559 +Ref: Boolean Ops-Footnote-1365898 +Node: Conditional Exp365989 +Node: Function Calls367716 +Node: Precedence371596 +Node: Locales375264 +Node: Expressions Summary376895 +Node: Patterns and Actions379436 +Node: Pattern Overview380552 +Node: Regexp Patterns382229 +Node: Expression Patterns382772 +Node: Ranges386552 +Node: BEGIN/END389658 +Node: Using BEGIN/END390420 +Ref: Using BEGIN/END-Footnote-1393156 +Node: I/O And BEGIN/END393262 +Node: BEGINFILE/ENDFILE395533 +Node: Empty398464 +Node: Using Shell Variables398781 +Node: Action Overview401064 +Node: Statements403391 +Node: If Statement405239 +Node: While Statement406737 +Node: Do Statement408781 +Node: For Statement409937 +Node: Switch Statement413089 +Node: Break Statement415477 +Node: Continue Statement417518 +Node: Next Statement419343 +Node: Nextfile Statement421713 +Node: Exit Statement424370 +Node: Built-in Variables426774 +Node: User-modified427901 +Ref: User-modified-Footnote-1435590 +Node: Auto-set435652 +Ref: Auto-set-Footnote-1448504 +Ref: Auto-set-Footnote-2448709 +Node: ARGC and ARGV448765 +Node: Pattern Action Summary452669 +Node: Arrays454892 +Node: Array Basics456441 +Node: Array Intro457267 +Ref: figure-array-elements459240 +Ref: Array Intro-Footnote-1461764 +Node: Reference to Elements461892 +Node: Assigning Elements464342 +Node: Array Example464833 +Node: Scanning an Array466565 +Node: Controlling Scanning469566 +Ref: Controlling Scanning-Footnote-1474739 +Node: Delete475055 +Ref: Delete-Footnote-1477806 +Node: Numeric Array Subscripts477863 +Node: Uninitialized Subscripts480046 +Node: Multidimensional481673 +Node: Multiscanning484786 +Node: Arrays of Arrays486375 +Node: Arrays Summary491038 +Node: Functions493143 +Node: Built-in494016 +Node: Calling Built-in495094 +Node: Numeric Functions497082 +Ref: Numeric Functions-Footnote-1501116 +Ref: Numeric Functions-Footnote-2501473 +Ref: Numeric Functions-Footnote-3501521 +Node: String Functions501790 +Ref: String Functions-Footnote-1524787 +Ref: String Functions-Footnote-2524916 +Ref: String Functions-Footnote-3525164 +Node: Gory Details525251 +Ref: table-sub-escapes527024 +Ref: table-sub-proposed528544 +Ref: table-posix-sub529908 +Ref: table-gensub-escapes531448 +Ref: Gory Details-Footnote-1532624 +Node: I/O Functions532775 +Ref: I/O Functions-Footnote-1539885 +Node: Time Functions540032 +Ref: Time Functions-Footnote-1550496 +Ref: Time Functions-Footnote-2550564 +Ref: Time Functions-Footnote-3550722 +Ref: Time Functions-Footnote-4550833 +Ref: Time Functions-Footnote-5550945 +Ref: Time Functions-Footnote-6551172 +Node: Bitwise Functions551438 +Ref: table-bitwise-ops552000 +Ref: Bitwise Functions-Footnote-1556245 +Node: Type Functions556414 +Node: I18N Functions557556 +Node: User-defined559201 +Node: Definition Syntax560005 +Ref: Definition Syntax-Footnote-1565409 +Node: Function Example565478 +Ref: Function Example-Footnote-1568118 +Node: Function Caveats568140 +Node: Calling A Function568658 +Node: Variable Scope569613 +Node: Pass By Value/Reference572601 +Node: Return Statement576111 +Node: Dynamic Typing579095 +Node: Indirect Calls580024 +Ref: Indirect Calls-Footnote-1589740 +Node: Functions Summary589868 +Node: Library Functions592518 +Ref: Library Functions-Footnote-1596136 +Ref: Library Functions-Footnote-2596279 +Node: Library Names596450 +Ref: Library Names-Footnote-1599923 +Ref: Library Names-Footnote-2600143 +Node: General Functions600229 +Node: Strtonum Function601257 +Node: Assert Function604159 +Node: Round Function607485 +Node: Cliff Random Function609026 +Node: Ordinal Functions610042 +Ref: Ordinal Functions-Footnote-1613107 +Ref: Ordinal Functions-Footnote-2613359 +Node: Join Function613570 +Ref: Join Function-Footnote-1615341 +Node: Getlocaltime Function615541 +Node: Readfile Function619277 +Node: Data File Management621116 +Node: Filetrans Function621748 +Node: Rewind Function625817 +Node: File Checking627375 +Ref: File Checking-Footnote-1628507 +Node: Empty Files628708 +Node: Ignoring Assigns630687 +Node: Getopt Function632241 +Ref: Getopt Function-Footnote-1643505 +Node: Passwd Functions643708 +Ref: Passwd Functions-Footnote-1652687 +Node: Group Functions652775 +Ref: Group Functions-Footnote-1660706 +Node: Walking Arrays660919 +Node: Library Functions Summary662522 +Node: Library Exercises663910 +Node: Sample Programs665190 +Node: Running Examples665960 +Node: Clones666688 +Node: Cut Program667912 +Node: Egrep Program677770 +Ref: Egrep Program-Footnote-1685357 +Node: Id Program685467 +Node: Split Program689121 +Ref: Split Program-Footnote-1692659 +Node: Tee Program692787 +Node: Uniq Program695574 +Node: Wc Program702997 +Ref: Wc Program-Footnote-1707262 +Node: Miscellaneous Programs707354 +Node: Dupword Program708567 +Node: Alarm Program710598 +Node: Translate Program715402 +Ref: Translate Program-Footnote-1719975 +Ref: Translate Program-Footnote-2720245 +Node: Labels Program720384 +Ref: Labels Program-Footnote-1723745 +Node: Word Sorting723829 +Node: History Sorting727872 +Node: Extract Program729708 +Node: Simple Sed737244 +Node: Igawk Program740306 +Ref: Igawk Program-Footnote-1754610 +Ref: Igawk Program-Footnote-2754811 +Node: Anagram Program754933 +Node: Signature Program758001 +Node: Programs Summary759248 +Node: Programs Exercises760463 +Ref: Programs Exercises-Footnote-1764594 +Node: Advanced Features764685 +Node: Nondecimal Data766633 +Node: Array Sorting768210 +Node: Controlling Array Traversal768907 +Node: Array Sorting Functions777187 +Ref: Array Sorting Functions-Footnote-1781079 +Node: Two-way I/O781273 +Ref: Two-way I/O-Footnote-1786217 +Ref: Two-way I/O-Footnote-2786396 +Node: TCP/IP Networking786478 +Node: Profiling789320 +Node: Advanced Features Summary796862 +Node: Internationalization798723 +Node: I18N and L10N800203 +Node: Explaining gettext800889 +Ref: Explaining gettext-Footnote-1805915 +Ref: Explaining gettext-Footnote-2806099 +Node: Programmer i18n806264 +Ref: Programmer i18n-Footnote-1811058 +Node: Translator i18n811107 +Node: String Extraction811901 +Ref: String Extraction-Footnote-1813034 +Node: Printf Ordering813120 +Ref: Printf Ordering-Footnote-1815902 +Node: I18N Portability815966 +Ref: I18N Portability-Footnote-1818415 +Node: I18N Example818478 +Ref: I18N Example-Footnote-1821184 +Node: Gawk I18N821256 +Node: I18N Summary821894 +Node: Debugger823233 +Node: Debugging824255 +Node: Debugging Concepts824696 +Node: Debugging Terms826552 +Node: Awk Debugging829149 +Node: Sample Debugging Session830041 +Node: Debugger Invocation830561 +Node: Finding The Bug831897 +Node: List of Debugger Commands838376 +Node: Breakpoint Control839708 +Node: Debugger Execution Control843372 +Node: Viewing And Changing Data846732 +Node: Execution Stack850090 +Node: Debugger Info851603 +Node: Miscellaneous Debugger Commands855597 +Node: Readline Support860781 +Node: Limitations861673 +Node: Debugging Summary863946 +Node: Arbitrary Precision Arithmetic865114 +Node: Computer Arithmetic866601 +Ref: Computer Arithmetic-Footnote-1870988 +Node: Math Definitions871045 +Ref: table-ieee-formats874334 +Ref: Math Definitions-Footnote-1874874 +Node: MPFR features874977 +Node: FP Math Caution876594 +Ref: FP Math Caution-Footnote-1877644 +Node: Inexactness of computations878013 +Node: Inexact representation878961 +Node: Comparing FP Values880316 +Node: Errors accumulate881280 +Node: Getting Accuracy882713 +Node: Try To Round885372 +Node: Setting precision886271 +Ref: table-predefined-precision-strings886953 +Node: Setting the rounding mode888746 +Ref: table-gawk-rounding-modes889110 +Ref: Setting the rounding mode-Footnote-1892564 +Node: Arbitrary Precision Integers892743 +Ref: Arbitrary Precision Integers-Footnote-1895724 +Node: POSIX Floating Point Problems895873 +Ref: POSIX Floating Point Problems-Footnote-1899749 +Node: Floating point summary899787 +Node: Dynamic Extensions901991 +Node: Extension Intro903543 +Node: Plugin License904808 +Node: Extension Mechanism Outline905493 +Ref: figure-load-extension905917 +Ref: figure-load-new-function907402 +Ref: figure-call-new-function908404 +Node: Extension API Description910388 +Node: Extension API Functions Introduction911838 +Node: General Data Types916705 +Ref: General Data Types-Footnote-1922398 +Node: Requesting Values922697 +Ref: table-value-types-returned923434 +Node: Memory Allocation Functions924392 +Ref: Memory Allocation Functions-Footnote-1927139 +Node: Constructor Functions927235 +Node: Registration Functions928993 +Node: Extension Functions929678 +Node: Exit Callback Functions931980 +Node: Extension Version String933228 +Node: Input Parsers933878 +Node: Output Wrappers943692 +Node: Two-way processors948208 +Node: Printing Messages950412 +Ref: Printing Messages-Footnote-1951489 +Node: Updating `ERRNO'951641 +Node: Accessing Parameters952380 +Node: Symbol Table Access953610 +Node: Symbol table by name954124 +Node: Symbol table by cookie956100 +Ref: Symbol table by cookie-Footnote-1960233 +Node: Cached values960296 +Ref: Cached values-Footnote-1963800 +Node: Array Manipulation963891 +Ref: Array Manipulation-Footnote-1964989 +Node: Array Data Types965028 +Ref: Array Data Types-Footnote-1967731 +Node: Array Functions967823 +Node: Flattening Arrays971697 +Node: Creating Arrays978549 +Node: Extension API Variables983280 +Node: Extension Versioning983916 +Node: Extension API Informational Variables985817 +Node: Extension API Boilerplate986903 +Node: Finding Extensions990707 +Node: Extension Example991267 +Node: Internal File Description991997 +Node: Internal File Ops996088 +Ref: Internal File Ops-Footnote-11007520 +Node: Using Internal File Ops1007660 +Ref: Using Internal File Ops-Footnote-11010007 +Node: Extension Samples1010275 +Node: Extension Sample File Functions1011799 +Node: Extension Sample Fnmatch1019367 +Node: Extension Sample Fork1020849 +Node: Extension Sample Inplace1022062 +Node: Extension Sample Ord1023737 +Node: Extension Sample Readdir1024573 +Ref: table-readdir-file-types1025429 +Node: Extension Sample Revout1026228 +Node: Extension Sample Rev2way1026819 +Node: Extension Sample Read write array1027560 +Node: Extension Sample Readfile1029439 +Node: Extension Sample API Tests1030539 +Node: Extension Sample Time1031064 +Node: gawkextlib1032379 +Node: Extension summary1035192 +Node: Extension Exercises1038885 +Node: Language History1039607 +Node: V7/SVR3.11041250 +Node: SVR41043570 +Node: POSIX1045012 +Node: BTL1046398 +Node: POSIX/GNU1047132 +Node: Feature History1052848 +Node: Common Extensions1065939 +Node: Ranges and Locales1067251 +Ref: Ranges and Locales-Footnote-11071868 +Ref: Ranges and Locales-Footnote-21071895 +Ref: Ranges and Locales-Footnote-31072129 +Node: Contributors1072350 +Node: History summary1077775 +Node: Installation1079144 +Node: Gawk Distribution1080095 +Node: Getting1080579 +Node: Extracting1081403 +Node: Distribution contents1083045 +Node: Unix Installation1088762 +Node: Quick Installation1089379 +Node: Additional Configuration Options1091821 +Node: Configuration Philosophy1093559 +Node: Non-Unix Installation1095910 +Node: PC Installation1096368 +Node: PC Binary Installation1097679 +Node: PC Compiling1099527 +Ref: PC Compiling-Footnote-11102526 +Node: PC Testing1102631 +Node: PC Using1103807 +Node: Cygwin1107959 +Node: MSYS1108768 +Node: VMS Installation1109266 +Node: VMS Compilation1110062 +Ref: VMS Compilation-Footnote-11111284 +Node: VMS Dynamic Extensions1111342 +Node: VMS Installation Details1112715 +Node: VMS Running1114967 +Node: VMS GNV1117801 +Node: VMS Old Gawk1118524 +Node: Bugs1118994 +Node: Other Versions1122998 +Node: Installation summary1129222 +Node: Notes1130278 +Node: Compatibility Mode1131143 +Node: Additions1131925 +Node: Accessing The Source1132850 +Node: Adding Code1134286 +Node: New Ports1140464 +Node: Derived Files1144945 +Ref: Derived Files-Footnote-11150420 +Ref: Derived Files-Footnote-21150454 +Ref: Derived Files-Footnote-31151050 +Node: Future Extensions1151164 +Node: Implementation Limitations1151770 +Node: Extension Design1153018 +Node: Old Extension Problems1154172 +Ref: Old Extension Problems-Footnote-11155689 +Node: Extension New Mechanism Goals1155746 +Ref: Extension New Mechanism Goals-Footnote-11159106 +Node: Extension Other Design Decisions1159295 +Node: Extension Future Growth1161401 +Node: Old Extension Mechanism1162237 +Node: Notes summary1163999 +Node: Basic Concepts1165185 +Node: Basic High Level1165866 +Ref: figure-general-flow1166138 +Ref: figure-process-flow1166737 +Ref: Basic High Level-Footnote-11169966 +Node: Basic Data Typing1170151 +Node: Glossary1173479 +Node: Copying1198631 +Node: GNU Free Documentation License1236187 +Node: Index1261323 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 1c87978b..43da36ad 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -53,11 +53,16 @@ @c applies to and all the info about who's publishing this edition @c These apply across the board. -@set UPDATE-MONTH August, 2014 +@set UPDATE-MONTH September, 2014 @set VERSION 4.1 -@set PATCHLEVEL 1 +@set PATCHLEVEL 2 +@ifset FOR_PRINT +@set TITLE Effective AWK Programming +@end ifset +@ifclear FOR_PRINT @set TITLE GAWK: Effective AWK Programming +@end ifclear @set SUBTITLE A User's Guide for GNU Awk @set EDITION 4.1 @@ -1088,7 +1093,7 @@ books on Unix, I found the gray AWK book, a.k.a.@: Aho, Kernighan and Weinberger, @cite{The AWK Programming Language}, Addison-Wesley, 1988. AWK's simple programming paradigm---find a pattern in the input and then perform an action---often reduced complex or tedious -data manipulations to few lines of code. I was excited to try my +data manipulations to a few lines of code. I was excited to try my hand at programming in AWK. Alas, the @command{awk} on my computer was a limited version of the @@ -1222,7 +1227,7 @@ March, 2001 <affiliation><jobtitle>Nof Ayalon</jobtitle></affiliation> <affiliation><jobtitle>ISRAEL</jobtitle></affiliation> </author> - <date>June, 2014</date> + <date>December, 2014</date> </prefaceinfo> @end docbook @@ -1244,7 +1249,7 @@ and with the Unix version of @command{awk} maintained by Brian Kernighan. This means that all properly written @command{awk} programs should work with @command{gawk}. -Thus, we usually don't distinguish between @command{gawk} and other +So most of the time, we don't distinguish between @command{gawk} and other @command{awk} implementations. @cindex @command{awk}, POSIX and, See Also POSIX @command{awk} @@ -1291,15 +1296,15 @@ Sort data Perform simple network communications @item -Profile and debug @command{awk} programs. +Profile and debug @command{awk} programs @item -Extend the language with functions written in C or C++. +Extend the language with functions written in C or C++ @end itemize This @value{DOCUMENT} teaches you about the @command{awk} language and how you can use it effectively. You should already be familiar with basic -system commands, such as @command{cat} and @command{ls},@footnote{These commands +system commands, such as @command{cat} and @command{ls},@footnote{These utilities are available on POSIX-compliant systems, as well as on traditional Unix-based systems. If you are using some other operating system, you still need to be familiar with the ideas of I/O redirection and pipes.} as well as basic shell @@ -1321,10 +1326,9 @@ Microsoft Windows @ifclear FOR_PRINT (all versions) and OS/2 PCs, @end ifclear -and OpenVMS. -(Some other, obsolete systems to which @command{gawk} was once ported -are no longer supported and the code for those systems -has been removed.) +and OpenVMS.@footnote{Some other, obsolete systems to which @command{gawk} +was once ported are no longer supported and the code for those systems +has been removed.} @menu * History:: The history of @command{gawk} and @@ -1516,7 +1520,7 @@ All appear in the index, under the heading ``sidebar.'' Most of the time, the examples use complete @command{awk} programs. Some of the more advanced sections show only the part of the @command{awk} -program that illustrates the concept currently being described. +program that illustrates the concept being described. While this @value{DOCUMENT} is aimed principally at people who have not been exposed @@ -1574,9 +1578,9 @@ sorting arrays in @command{gawk}. It also describes how @command{gawk} provides arrays of arrays. @ref{Functions}, -describes the built-in functions @command{awk} and -@command{gawk} provide, as well as how to define -your own functions. +describes the built-in functions @command{awk} and @command{gawk} provide, +as well as how to define your own functions. It also discusses how +@command{gawk} lets you call functions indirectly. Part II shows how to use @command{awk} and @command{gawk} for problem solving. There is lots of code here for you to read and learn from. @@ -1649,9 +1653,10 @@ printed edition. You may find them online, as follows: @uref{http://www.gnu.org/software/gawk/manual/html_node/Notes.html, The appendix on implementation notes} -describes how to disable @command{gawk}'s extensions, as -well as how to contribute new code to @command{gawk}, -and some possible future directions for @command{gawk} development. +describes how to disable @command{gawk}'s extensions, how to contribute +new code to @command{gawk}, where to find information on some possible +future directions for @command{gawk} development, and the design decisions +behind the extension API. @uref{http://www.gnu.org/software/gawk/manual/html_node/Basic-Concepts.html, The appendix on basic concepts} @@ -1669,7 +1674,7 @@ The GNU FDL} is the license that covers this @value{DOCUMENT}. Some of the chapters have exercise sections; these have also been -omitted from the print edition. +omitted from the print edition but are available online. @end ifset @ifclear FOR_PRINT @@ -1892,7 +1897,7 @@ The FSF published the first two editions under the title @cite{The GNU Awk User's Guide}. @ifset FOR_PRINT SSC published two editions of the @value{DOCUMENT} under the -title @cite{Effective awk Programming}, and in O'Reilly published +title @cite{Effective awk Programming}, and O'Reilly published the third edition in 2001. @end ifset @@ -1924,7 +1929,7 @@ for information on submitting problem reports electronically. @unnumberedsec How to Stay Current It may be you have a version of @command{gawk} which is newer than the -one described in this @value{DOCUMENT}. To find out what has changed, +one described here. To find out what has changed, you should first look at the @file{NEWS} file in the @command{gawk} distribution, which provides a high level summary of what changed in each release. @@ -2146,7 +2151,7 @@ take advantage of those opportunities. Arnold Robbins @* Nof Ayalon @* ISRAEL @* -May, 2014 +December, 2014 @end iftex @ifnotinfo @@ -2365,7 +2370,7 @@ to keep you from worrying about the complexities of computer programming: @example -$ @kbd{awk "BEGIN @{ print "Don\47t Panic!" @}"} +$ @kbd{awk 'BEGIN @{ print "Don\47t Panic!" @}'} @print{} Don't Panic! @end example @@ -2373,11 +2378,11 @@ $ @kbd{awk "BEGIN @{ print "Don\47t Panic!" @}"} reading any input. If there are no other statements in your program, as is the case here, @command{awk} just stops, instead of trying to read input it doesn't know how to process. -The @samp{\47} is a magic way of getting a single quote into +The @samp{\47} is a magic way (explained later) of getting a single quote into the program, without having to engage in ugly shell quoting tricks. @quotation NOTE -As a side note, if you use Bash as your shell, you should execute the +If you use Bash as your shell, you should execute the command @samp{set +H} before running this program interactively, to disable the C shell-style command history, which treats @samp{!} as a special character. We recommend putting this command into your personal @@ -2407,7 +2412,7 @@ $ @kbd{awk '@{ print @}'} @cindex @command{awk} programs, running @cindex @command{awk} programs, lengthy @cindex files, @command{awk} programs in -Sometimes your @command{awk} programs can be very long. In this case, it is +Sometimes @command{awk} programs are very long. In these cases, it is more convenient to put the program into a separate file. In order to tell @command{awk} to use that file for its program, you type: @@ -2437,7 +2442,7 @@ awk -f advice does the same thing as this one: @example -awk "BEGIN @{ print \"Don't Panic!\" @}" +awk 'BEGIN @{ print "Don\47t Panic!" @}' @end example @cindex quoting in @command{gawk} command lines @@ -2449,6 +2454,8 @@ specify with @option{-f}, because most @value{FN}s don't contain any of the shel special characters. Notice that in @file{advice}, the @command{awk} program did not have single quotes around it. The quotes are only needed for programs that are provided on the @command{awk} command line. +(Also, placing the program in a file allows us to use a literal single quote in the program +text, instead of the magic @samp{\47}.) @c STARTOFRANGE sq1x @cindex single quote (@code{'}) in @command{gawk} command lines @@ -2512,7 +2519,7 @@ written in @command{awk}. according to the instructions in your program. (This is different from a @dfn{compiled} language such as C, where your program is first compiled into machine code that is executed directly by your system's -hardware.) The @command{awk} utility is thus termed an @dfn{interpreter}. +processor.) The @command{awk} utility is thus termed an @dfn{interpreter}. Many modern languages are interperted. The line beginning with @samp{#!} lists the full @value{FN} of an @@ -2521,9 +2528,9 @@ to pass to that interpreter. The operating system then runs the interpreter with the given argument and the full argument list of the executed program. The first argument in the list is the full @value{FN} of the @command{awk} program. The rest of the argument list contains -either options to @command{awk}, or @value{DF}s, or both. Note that on +either options to @command{awk}, or @value{DF}s, or both. (Note that on many systems @command{awk} may be found in @file{/usr/bin} instead of -in @file{/bin}. Caveat Emptor. +in @file{/bin}.) Some systems limit the length of the interpreter name to 32 characters. Often, this can be dealt with by using a symbolic link. @@ -2562,7 +2569,7 @@ to provide your script name. according to the instructions in your program. (This is different from a @dfn{compiled} language such as C, where your program is first compiled into machine code that is executed directly by your system's -hardware.) The @command{awk} utility is thus termed an @dfn{interpreter}. +processor.) The @command{awk} utility is thus termed an @dfn{interpreter}. Many modern languages are interperted. The line beginning with @samp{#!} lists the full @value{FN} of an @@ -2571,9 +2578,9 @@ to pass to that interpreter. The operating system then runs the interpreter with the given argument and the full argument list of the executed program. The first argument in the list is the full @value{FN} of the @command{awk} program. The rest of the argument list contains -either options to @command{awk}, or @value{DF}s, or both. Note that on +either options to @command{awk}, or @value{DF}s, or both. (Note that on many systems @command{awk} may be found in @file{/usr/bin} instead of -in @file{/bin}. Caveat Emptor. +in @file{/bin}.) Some systems limit the length of the interpreter name to 32 characters. Often, this can be dealt with by using a symbolic link. @@ -2752,8 +2759,14 @@ Thus, the example seen @ifnotinfo previously @end ifnotinfo -in @ref{Read Terminal}, -is applicable: +in @ref{Read Terminal}: + +@example +awk 'BEGIN @{ print "Don\47t Panic!" @}' +@end example + +@noindent +could instead be written this way: @example $ @kbd{awk "BEGIN @{ print \"Don't Panic!\" @}"} @@ -2848,6 +2861,9 @@ $ awk -v sq="'" 'BEGIN @{ print "Here is a single quote <" sq ">" @}' @print{} Here is a single quote <'> @end example +(Here, the two string constants and the value of @code{sq} are concatenated +into a single string which is printed by @code{print}.) + If you really need both single and double quotes in your @command{awk} program, it is probably best to move it into a separate file, where the shell won't be part of the picture, and you can say what you mean. @@ -2911,7 +2927,7 @@ The second @value{DF}, called @file{inventory-shipped}, contains information about monthly shipments. In both files, each line is considered to be one @dfn{record}. -In the @value{DF} @file{mail-list}, each record contains the name of a person, +In @file{mail-list}, each record contains the name of a person, his/her phone number, his/her email-address, and a code for their relationship with the author of the list. The columns are aligned using spaces. @@ -3071,7 +3087,7 @@ Print the length of the longest line in @file{data}: @example expand data | awk '@{ if (x < length($0)) x = length($0) @} - END @{ print "maximum line length is " x @}' + END @{ print "maximum line length is " x @}' @end example This example differs slightly from the previous one: @@ -3103,7 +3119,7 @@ Print the total number of bytes used by @var{files}: @example ls -l @var{files} | awk '@{ x += $5 @} - END @{ print "total bytes: " x @}' + END @{ print "total bytes: " x @}' @end example @item @@ -3147,7 +3163,7 @@ the program would print the odd-numbered lines. @cindex @command{awk} programs The @command{awk} utility reads the input files one line at a -time. For each line, @command{awk} tries the patterns of each of the rules. +time. For each line, @command{awk} tries the patterns of each rule. If several patterns match, then several actions execute in the order in which they appear in the @command{awk} program. If no patterns match, then no actions run. @@ -3155,7 +3171,7 @@ no actions run. After processing all the rules that match the line (and perhaps there are none), @command{awk} reads the next line. (However, @pxref{Next Statement}, -and also @pxref{Nextfile Statement}). +and also @pxref{Nextfile Statement}.) This continues until the program reaches the end of the file. For example, the following @command{awk} program contains two rules: @@ -3229,13 +3245,12 @@ the file was last modified. Its output looks like this: @noindent @cindex line continuations, with C shell The first field contains read-write permissions, the second field contains -the number of links to the file, and the third field identifies the owner of -the file. The fourth field identifies the group of the file. -The fifth field contains the size of the file in bytes. The +the number of links to the file, and the third field identifies the file's owner. +The fourth field identifies the file's group. +The fifth field contains the file's size in bytes. The sixth, seventh, and eighth fields contain the month, day, and time, respectively, that the file was last modified. Finally, the ninth field -contains the @value{FN}.@footnote{The @samp{LC_ALL=C} is -needed to produce this traditional-style output from @command{ls}.} +contains the @value{FN}. @c @cindex automatic initialization @cindex initialization, automatic @@ -3645,7 +3660,7 @@ more than once, setting another variable each time, like this: Using @option{-v} to set the values of the built-in variables may lead to surprising results. @command{awk} will reset the values of those variables as it needs to, possibly ignoring any -predefined value you may have given. +initial value you may have given. @end quotation @item -W @var{gawk-opt} @@ -3728,7 +3743,7 @@ Print the short version of the General Public License and then exit. @cindex variables, global, printing list of Print a sorted list of global variables, their types, and final values to @var{file}. If no @var{file} is provided, print this -list to the file named @file{awkvars.out} in the current directory. +list to a file named @file{awkvars.out} in the current directory. No space is allowed between the @option{-d} and @var{file}, if @var{file} is supplied. @@ -3824,7 +3839,7 @@ that @command{gawk} accepts and then exit. @cindex @option{-i} option @cindex @option{--include} option @cindex @command{awk} programs, location of -Read @command{awk} source library from @var{source-file}. This option +Read an @command{awk} source library from @var{source-file}. This option is completely equivalent to using the @code{@@include} directive inside your program. This option is very similar to the @option{-f} option, but there are two important differences. First, when @option{-i} is @@ -3848,7 +3863,7 @@ environment variable. The correct library suffix for your platform will be supplied by default, so it need not be specified in the extension name. The extension initialization routine should be named @code{dl_load()}. An alternative is to use the @code{@@load} keyword inside the program to load -a shared library. This feature is described in detail in @ref{Dynamic Extensions}. +a shared library. This advanced feature is described in detail in @ref{Dynamic Extensions}. @item @option{-L}[@var{value}] @itemx @option{--lint}[@code{=}@var{value}] @@ -4062,6 +4077,7 @@ if they had been concatenated together into one big file. This is useful for creating libraries of @command{awk} functions. These functions can be written once and then retrieved from a standard place, instead of having to be included into each individual program. +The @option{-i} option is similar in this regard. (As mentioned in @ref{Definition Syntax}, function names must be unique.) @@ -4135,15 +4151,18 @@ Any additional arguments on the command line are normally treated as input files to be processed in the order specified. However, an argument that has the form @code{@var{var}=@var{value}}, assigns the value @var{value} to the variable @var{var}---it does not specify a -file at all. -(See -@ref{Assignment Options}.) +file at all. (See @ref{Assignment Options}.) In the following example, +@var{count=1} is a variable assignment, not a @value{FN}: + +@example +awk -f program.awk file1 count=1 file2 +@end example @cindex @command{gawk}, @code{ARGIND} variable in @cindex @code{ARGIND} variable, command-line arguments @cindex @code{ARGV} array, indexing into @cindex @code{ARGC}/@code{ARGV} variables, command-line arguments -All these arguments are made available to your @command{awk} program in the +All the command-line arguments are made available to your @command{awk} program in the @code{ARGV} array (@pxref{Built-in Variables}). Command-line options and the program text (if present) are omitted from @code{ARGV}. All other arguments, including variable assignments, are @@ -4274,15 +4293,15 @@ separated by colons@footnote{Semicolons on MS-Windows and MS-DOS.}. @command{ga @samp{.:/usr/local/share/awk}.@footnote{Your version of @command{gawk} may use a different directory; it will depend upon how @command{gawk} was built and installed. The actual -directory is the value of @samp{$(datadir)} generated when +directory is the value of @code{$(datadir)} generated when @command{gawk} was configured. You probably don't need to worry about this, though.} The search path feature is particularly helpful for building libraries of useful @command{awk} functions. The library files can be placed in a standard directory in the default path and then specified on -the command line with a short @value{FN}. Otherwise, the full @value{FN} -would have to be typed for each file. +the command line with a short @value{FN}. Otherwise, you would have to +type the full @value{FN} for each file. By using the @option{-i} option, or the @option{-e} and @option{-f} options, your command-line @command{awk} programs can use facilities in @command{awk} library files @@ -4291,25 +4310,23 @@ Path searching is not done if @command{gawk} is in compatibility mode. This is true for both @option{--traditional} and @option{--posix}. @xref{Options}. -If the source code is not found after the initial search, the path is searched +If the source code file is not found after the initial search, the path is searched again after adding the default @samp{.awk} suffix to the @value{FN}. -@quotation NOTE -@c 4/2014: -@c using @samp{.} to get quotes, since @file{} no longer supplies them. -To include -the current directory in the path, either place -@samp{.} explicitly in the path or write a null entry in the -path. (A null entry is indicated by starting or ending the path with a -colon or by placing two colons next to each other [@samp{::}].) -This path search mechanism is similar +@command{gawk}'s path search mechanism is similar to the shell's. (See @uref{http://www.gnu.org/software/bash/manual/, -@cite{The Bourne-Again SHell manual}.}) +@cite{The Bourne-Again SHell manual}}.) +It treats a null entry in the path as indicating the current +directory. +(A null entry is indicated by starting or ending the path with a +colon or by placing two colons next to each other [@samp{::}].) -However, @command{gawk} always looks in the current directory @emph{before} -searching @env{AWKPATH}, so there is no real reason to include -the current directory in the search path. +@quotation NOTE +@command{gawk} always looks in the current directory @emph{before} +searching @env{AWKPATH}. Thus, while you can include the current directory +in the search path, either explicitly or with a null entry, there is no +real reason to do so. @c Prior to 4.0, gawk searched the current directory after the @c path search, but it's not worth documenting it. @end quotation @@ -4350,16 +4367,6 @@ behavior, but they are more specialized. Those in the following list are meant to be used by regular users. @table @env -@item POSIXLY_CORRECT -Causes @command{gawk} to switch to POSIX compatibility -mode, disabling all traditional and GNU extensions. -@xref{Options}. - -@item GAWK_SOCK_RETRIES -Controls the number of times @command{gawk} attempts to -retry a two-way TCP/IP (socket) connection before giving up. -@xref{TCP/IP Networking}. - @item GAWK_MSEC_SLEEP Specifies the interval between connection retries, in milliseconds. On systems that do not support @@ -4370,6 +4377,16 @@ the value is rounded up to an integral number of seconds. Specifies the time, in milliseconds, for @command{gawk} to wait for input before returning with an error. @xref{Read Timeout}. + +@item GAWK_SOCK_RETRIES +Controls the number of times @command{gawk} attempts to +retry a two-way TCP/IP (socket) connection before giving up. +@xref{TCP/IP Networking}. + +@item POSIXLY_CORRECT +Causes @command{gawk} to switch to POSIX compatibility +mode, disabling all traditional and GNU extensions. +@xref{Options}. @end table The environment variables in the following list are meant @@ -4384,7 +4401,7 @@ file as the size of the memory buffer to allocate for I/O. Otherwise, the value should be a number, and @command{gawk} uses that number as the size of the buffer to allocate. (When this variable is not set, @command{gawk} uses the smaller of the file's size and the ``default'' -blocksize, which is usually the filesystems I/O blocksize.) +blocksize, which is usually the filesystem's I/O blocksize.) @item AWK_HASH If this variable exists with a value of @samp{gst}, @command{gawk} @@ -4399,10 +4416,11 @@ for debugging problems on filesystems on non-POSIX operating systems where I/O is performed in records, not in blocks. @item GAWK_MSG_SRC -If this variable exists, @command{gawk} includes the source file -name and line number from which warning and/or fatal messages +If this variable exists, @command{gawk} includes the file +name and line number within the @command{gawk} source code +from which warning and/or fatal messages are generated. Its purpose is to help isolate the source of a -message, since there can be multiple places which produce the +message, since there are multiple places which produce the same warning or error message. @item GAWK_NO_DFA @@ -4415,8 +4433,11 @@ coordinate with each other.) @item GAWK_NO_PP_RUN If this variable exists, then when invoked with the @option{--pretty-print} -option, @command{gawk} skips running the program. This variable will -not survive into the next major release. +option, @command{gawk} skips running the program. + +@quotation CAUTION +This variable will not survive into the next major release. +@end quotation @item GAWK_STACKSIZE This specifies the amount by which @command{gawk} should grow its @@ -4620,6 +4641,7 @@ that requires access to an extension. @ref{Dynamic Extensions}, describes how to write extensions (in C or C++) that can be loaded with either @code{@@load} or the @option{-l} option. +It also describes the @code{ordchr} extension. @node Obsolete @section Obsolete Options and/or Features @@ -4688,15 +4710,15 @@ awk '@{ sum += $1 @} END @{ print sum @}' @end example @command{gawk} actually supports this but it is purposely undocumented -because it is considered bad style. The correct way to write such a program -is either +because it is bad style. The correct way to write such a program +is either: @example awk '@{ sum += $1 @} ; END @{ print sum @}' @end example @noindent -or +or: @example awk '@{ sum += $1 @} @@ -4704,8 +4726,7 @@ awk '@{ sum += $1 @} @end example @noindent -@xref{Statements/Lines}, for a fuller -explanation. +@xref{Statements/Lines}, for a fuller explanation. You can insert newlines after the @samp{;} in @code{for} loops. This seems to have been a long-undocumented feature in Unix @command{awk}. @@ -4745,7 +4766,8 @@ affects how @command{awk} processes input. @item You can use a single minus sign (@samp{-}) to refer to standard input -on the command line. +on the command line. @command{gawk} also lets you use the special +@value{FN} @file{/dev/stdin}. @item @command{gawk} pays attention to a number of environment variables. @@ -4934,7 +4956,7 @@ such as TAB or newline. While there is nothing to stop you from entering most unprintable characters directly in a string constant or regexp constant, they may look ugly. -The following table lists +The following list presents all the escape sequences used in @command{awk} and what they represent. Unless noted otherwise, all these escape sequences apply to both string constants and regexp constants: @@ -5049,13 +5071,13 @@ characters @samp{a+b}. @cindex @code{\} (backslash), in escape sequences @cindex portability For complete portability, do not use a backslash before any character not -shown in the previous list. +shown in the previous list and that is not an operator. To summarize: @itemize @value{BULLET} @item -The escape sequences in the table above are always processed first, +The escape sequences in the list above are always processed first, for both string constants and regexp constants. This happens very early, as soon as @command{awk} reads your program. @@ -5228,7 +5250,7 @@ are recognized and converted into corresponding real characters as the very first step in processing regexps. Here is a list of metacharacters. All characters that are not escape -sequences and that are not listed in the table stand for themselves: +sequences and that are not listed in the following stand for themselves: @c Use @asis so the docbook comes out ok. Sigh. @table @asis @@ -5485,7 +5507,7 @@ characters to be matched. @cindex Extended Regular Expressions (EREs) @cindex EREs (Extended Regular Expressions) @cindex @command{egrep} utility -This treatment of @samp{\} in bracket expressions +The treatment of @samp{\} in bracket expressions is compatible with other @command{awk} implementations and is also mandated by POSIX. The regular expressions in @command{awk} are a superset @@ -5602,11 +5624,11 @@ Consider the following: echo aaaabcd | awk '@{ sub(/a+/, "<A>"); print @}' @end example -This example uses the @code{sub()} function (which we haven't discussed yet; -@pxref{String Functions}) -to make a change to the input record. Here, the regexp @code{/a+/} -indicates ``one or more @samp{a} characters,'' and the replacement -text is @samp{<A>}. +This example uses the @code{sub()} function to make a change to the input +record. (@code{sub()} replaces the first instance of any text matched +by the first argument with the string provided as the second argument; +@pxref{String Functions}). Here, the regexp @code{/a+/} indicates ``one +or more @samp{a} characters,'' and the replacement text is @samp{<A>}. The input contains four @samp{a} characters. @command{awk} (and POSIX) regular expressions always match @@ -5722,7 +5744,7 @@ intend a regexp match. @cindex regular expressions, dynamic, with embedded newlines @cindex newlines, in dynamic regexps -Some versions of @command{awk} do not allow the newline +Some older versions of @command{awk} do not allow the newline character to be used inside a bracket expression for a dynamic regexp: @example @@ -5731,7 +5753,7 @@ $ @kbd{awk '$0 ~ "[ \t\n]"'} @error{} ]... @error{} source line number 1 @error{} context is -@error{} >>> <<< +@error{} $0 ~ "[ >>> \t\n]" <<< @end example @cindex newlines, in regexp constants @@ -5760,7 +5782,7 @@ occur often in practice, but it's worth noting for future reference. @cindex regular expressions, dynamic, with embedded newlines @cindex newlines, in dynamic regexps -Some versions of @command{awk} do not allow the newline +Some older versions of @command{awk} do not allow the newline character to be used inside a bracket expression for a dynamic regexp: @example @@ -5769,7 +5791,7 @@ $ @kbd{awk '$0 ~ "[ \t\n]"'} @error{} ]... @error{} source line number 1 @error{} context is -@error{} >>> <<< +@error{} $0 ~ "[ >>> \t\n]" <<< @end example @cindex newlines, in regexp constants @@ -6093,11 +6115,6 @@ Within bracket expressions, POSIX character classes let you specify certain groups of characters in a locale-independent fashion. @item -@command{gawk}'s @code{IGNORECASE} variable lets you control the -case sensitivity of regexp matching. In other @command{awk} -versions, use @code{tolower()} or @code{toupper()}. - -@item Regular expressions match the leftmost longest text in the string being matched. This matters for cases where you need to know the extent of the match, such as for text substitution and when the record separator @@ -6107,6 +6124,11 @@ is a regexp. Matching expressions may use dynamic regexps, that is, string values treated as regular expressions. +@item +@command{gawk}'s @code{IGNORECASE} variable lets you control the +case sensitivity of regexp matching. In other @command{awk} +versions, use @code{tolower()} or @code{toupper()}. + @end itemize @c ENDOFRANGE regexp @@ -6174,7 +6196,7 @@ used with it do not have to be named on the @command{awk} command line @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. +called @code{FNR} which is reset to zero every time 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. @@ -6304,7 +6326,8 @@ Using an unusual character such as @samp{/} is more likely to produce correct behavior in the majority of cases, but there are no guarantees. The moral is: Know Your Data. -There is one unusual case, that occurs when @command{gawk} is +When using regular characters as the record separator, +there is one unusual case that occurs when @command{gawk} is being fully POSIX-compliant (@pxref{Options}). Then, the following (extreme) pipeline prints a surprising @samp{1}: @@ -6393,7 +6416,7 @@ $ @kbd{echo record 1 AAAA record 2 BBBB record 3 |} @noindent The square brackets delineate the contents of @code{RT}, letting you -see the leading and trailing whitespace. The final value of @code{RT} +see the leading and trailing whitespace. The final value of @code{RT} is a newline. @xref{Simple Sed}, for a more useful example of @code{RS} as a regexp and @code{RT}. @@ -6412,7 +6435,7 @@ metacharacters match the beginning and end of a @emph{string}, and not the beginning and end of a @emph{line}. As a result, something like @samp{RS = "^[[:upper:]]"} can only match at the beginning of a file. This is because @command{gawk} views the input file as one long string -that happens to contain newline characters in it. +that happens to contain newline characters. It is thus best to avoid anchor characters in the value of @code{RS}. @end quotation @@ -6422,7 +6445,7 @@ variable are @command{gawk} extensions; they are not available in compatibility mode (@pxref{Options}). In compatibility mode, only the first character of the value of -@code{RS} is used to determine the end of the record. +@code{RS} determines the end of the record. @cindex sidebar, @code{RS = "\0"} Is Not Portable @ifdocbook @@ -6463,10 +6486,11 @@ about.} store strings internally as C-style strings. C strings use the It happens that recent versions of @command{mawk} can use the @value{NUL} character as a record separator. However, this is a special case: @command{mawk} does not allow embedded @value{NUL} characters in strings. +(This may change in a future version of @command{mawk}.) @cindex records, treating files as @cindex treating files, as single records -@xref{Readfile Function}, for an interesting, portable way to read +@xref{Readfile Function}, for an interesting way to read whole files. If you are using @command{gawk}, see @ref{Extension Sample Readfile}, for another option. @@ -6513,10 +6537,11 @@ about.} store strings internally as C-style strings. C strings use the It happens that recent versions of @command{mawk} can use the @value{NUL} character as a record separator. However, this is a special case: @command{mawk} does not allow embedded @value{NUL} characters in strings. +(This may change in a future version of @command{mawk}.) @cindex records, treating files as @cindex treating files, as single records -@xref{Readfile Function}, for an interesting, portable way to read +@xref{Readfile Function}, for an interesting way to read whole files. If you are using @command{gawk}, see @ref{Extension Sample Readfile}, for another option. @end cartouche @@ -6598,15 +6623,11 @@ $ @kbd{awk '$1 ~ /li/ @{ print $0 @}' mail-list} @noindent This example prints each record in the file @file{mail-list} whose first -field contains the string @samp{li}. The operator @samp{~} is called a -@dfn{matching operator} -(@pxref{Regexp Usage}); -it tests whether a string (here, the field @code{$1}) matches a given regular -expression. +field contains the string @samp{li}. -By contrast, the following example -looks for @samp{li} in @emph{the entire record} and prints the first -field and the last field for each matching input record: +By contrast, the following example looks for @samp{li} in @emph{the +entire record} and prints the first and last fields for each matching +input record: @example $ @kbd{awk '/li/ @{ print $1, $NF @}' mail-list} @@ -6729,8 +6750,8 @@ It is also possible to also assign contents to fields that are out of range. For example: @example -$ awk '@{ $6 = ($5 + $4 + $3 + $2) -> print $6 @}' inventory-shipped +$ @kbd{awk '@{ $6 = ($5 + $4 + $3 + $2)} +> @kbd{ print $6 @}' inventory-shipped} @print{} 168 @print{} 297 @print{} 301 @@ -6819,7 +6840,7 @@ Here is an example: @example $ echo a b c d e f | awk '@{ print "NF =", NF; -> NF = 3; print $0 @}' +> NF = 3; print $0 @}' @print{} NF = 6 @print{} a b c @end example @@ -6827,7 +6848,7 @@ $ echo a b c d e f | awk '@{ print "NF =", NF; @cindex portability, @code{NF} variable@comma{} decrementing @quotation CAUTION Some versions of @command{awk} don't -rebuild @code{$0} when @code{NF} is decremented. Caveat emptor. +rebuild @code{$0} when @code{NF} is decremented. @end quotation Finally, there are times when it is convenient to force @@ -6863,7 +6884,7 @@ record, exactly as it was read from the input. This includes any leading or trailing whitespace, and the exact whitespace (or other characters) that separate the fields. -It is a not-uncommon error to try to change the field separators +It is a common error to try to change the field separators in a record simply by setting @code{FS} and @code{OFS}, and then expecting a plain @samp{print} or @samp{print $0} to print the modified record. @@ -6888,7 +6909,7 @@ record, exactly as it was read from the input. This includes any leading or trailing whitespace, and the exact whitespace (or other characters) that separate the fields. -It is a not-uncommon error to try to change the field separators +It is a common error to try to change the field separators in a record simply by setting @code{FS} and @code{OFS}, and then expecting a plain @samp{print} or @samp{print $0} to print the modified record. @@ -7092,9 +7113,10 @@ $ @kbd{echo ' a b c d' | awk '@{ print; $2 = $2; print @}'} The first @code{print} statement prints the record as it was read, with leading whitespace intact. The assignment to @code{$2} rebuilds @code{$0} by concatenating @code{$1} through @code{$NF} together, -separated by the value of @code{OFS}. Because the leading whitespace -was ignored when finding @code{$1}, it is not part of the new @code{$0}. -Finally, the last @code{print} statement prints the new @code{$0}. +separated by the value of @code{OFS} (which is a space by default). +Because the leading whitespace was ignored when finding @code{$1}, +it is not part of the new @code{$0}. Finally, the last @code{print} +statement prints the new @code{$0}. @cindex @code{FS}, containing @code{^} @cindex @code{^} (caret), in @code{FS} @@ -7116,7 +7138,7 @@ also works this way. For example: @example $ @kbd{echo 'xxAA xxBxx C' |} > @kbd{gawk -F '(^x+)|( +)' '@{ for (i = 1; i <= NF; i++)} -> @kbd{printf "-->%s<--\n", $i @}'} +> @kbd{ printf "-->%s<--\n", $i @}'} @print{} --><-- @print{} -->AA<-- @print{} -->xxBxx<-- @@ -7179,12 +7201,7 @@ awk -F, '@var{program}' @var{input-files} @noindent sets @code{FS} to the @samp{,} character. Notice that the option uses an uppercase @samp{F} instead of a lowercase @samp{f}. The latter -option (@option{-f}) specifies a file -containing an @command{awk} program. Case is significant in command-line -options: -the @option{-F} and @option{-f} options have nothing to do with each other. -You can use both options at the same time to set the @code{FS} variable -@emph{and} get an @command{awk} program from a file. +option (@option{-f}) specifies a file containing an @command{awk} program. The value used for the argument to @option{-F} is processed in exactly the same way as assignments to the built-in variable @code{FS}. @@ -7298,7 +7315,7 @@ to @code{FS} (the backslash is stripped). This creates a regexp meaning If instead you want fields to be separated by a literal period followed by any single character, use @samp{FS = "\\.."}. -The following table summarizes how fields are split, based on the value +The following list summarizes how fields are split, based on the value of @code{FS} (@samp{==} means ``is equal to''): @table @code @@ -7319,8 +7336,7 @@ Leading and trailing matches of @var{regexp} delimit empty fields. @item FS == "" Each individual character in the record becomes a separate field. -(This is a @command{gawk} extension; it is not specified by the -POSIX standard.) +(This is a common extension; it is not specified by the POSIX standard.) @end table @cindex sidebar, Changing @code{FS} Does Not Affect the Fields @@ -7867,7 +7883,7 @@ BEGIN @{ RS = "" ; FS = "\n" @} Running the program produces the following output: @example -$ awk -f addrs.awk addresses +$ @kbd{awk -f addrs.awk addresses} @print{} Name is: Jane Doe @print{} Address is: 123 Main Street @print{} City and State are: Anywhere, SE 12345-6789 @@ -7879,12 +7895,9 @@ $ awk -f addrs.awk addresses @dots{} @end example -@xref{Labels Program}, for a more realistic -program that deals with address lists. -The following -table -summarizes how records are split, based on the -value of +@xref{Labels Program}, for a more realistic program that deals with +address lists. The following list summarizes how records are split, +based on the value of @ifinfo @code{RS}. (@samp{==} means ``is equal to.'') @@ -7919,8 +7932,8 @@ POSIX standard.) @cindex @command{gawk}, @code{RT} variable in @cindex @code{RT} variable -In all cases, @command{gawk} sets @code{RT} to the input text that matched the -value specified by @code{RS}. +If not in compatibility mode (@pxref{Options}), @command{gawk} sets +@code{RT} to the input text that matched the value specified by @code{RS}. But if the input file ended without any text that matches @code{RS}, then @command{gawk} sets @code{RT} to the null string. @c ENDOFRANGE recm @@ -8018,9 +8031,7 @@ processing on the next record @emph{right now}. For example: while (j == 0) @{ # get more text if (getline <= 0) @{ - m = "unexpected EOF or error" - m = (m ": " ERRNO) - print m > "/dev/stderr" + print("unexpected EOF or error:", ERRNO) > "/dev/stderr" exit @} # build up the line using string concatenation @@ -8289,7 +8300,7 @@ bletch @end example @noindent -Notice that this program ran the command @command{who} and printed the previous result. +Notice that this program ran the command @command{who} and printed the result. (If you try this program yourself, you will of course get different results, depending upon who is logged in on your system.) @@ -8314,7 +8325,7 @@ Unfortunately, @command{gawk} has not been consistent in its treatment of a construct like @samp{@w{"echo "} "date" | getline}. Most versions, including the current version, treat it at as @samp{@w{("echo "} "date") | getline}. -(This how BWK @command{awk} behaves.) +(This is also how BWK @command{awk} behaves.) Some versions changed and treated it as @samp{@w{"echo "} ("date" | getline)}. (This is how @command{mawk} behaves.) @@ -8342,7 +8353,7 @@ BEGIN @{ @end example In this version of @code{getline}, none of the built-in variables are -changed and the record is not split into fields. +changed and the record is not split into fields. However, @code{RT} is set. @ifinfo @c Thanks to Paul Eggert for initial wording here @@ -8450,7 +8461,7 @@ causes @command{awk} to set the value of @code{FILENAME}. Normally, @code{FILENAME} does not have a value inside @code{BEGIN} rules, because you have not yet started to process the command-line @value{DF}s. @value{DARKCORNER} -(@xref{BEGIN/END}, +(See @ref{BEGIN/END}; also @pxref{Auto-set}.) @item @@ -8497,7 +8508,7 @@ end of file is encountered, before the element in @code{a} is assigned? @command{gawk} treats @code{getline} like a function call, and evaluates the expression @samp{a[++c]} before attempting to read from @file{f}. However, some versions of @command{awk} only evaluate the expression once they -know that there is a string value to be assigned. Caveat Emptor. +know that there is a string value to be assigned. @end itemize @node Getline Summary @@ -8513,15 +8524,15 @@ Note: for each variant, @command{gawk} sets the @code{RT} built-in variable. @float Table,table-getline-variants @caption{@code{getline} Variants and What They Set} @multitable @columnfractions .33 .38 .27 -@headitem Variant @tab Effect @tab Standard / Extension -@item @code{getline} @tab Sets @code{$0}, @code{NF}, @code{FNR}, @code{NR}, and @code{RT} @tab Standard -@item @code{getline} @var{var} @tab Sets @var{var}, @code{FNR}, @code{NR}, and @code{RT} @tab Standard -@item @code{getline <} @var{file} @tab Sets @code{$0}, @code{NF}, and @code{RT} @tab Standard -@item @code{getline @var{var} < @var{file}} @tab Sets @var{var} and @code{RT} @tab Standard -@item @var{command} @code{| getline} @tab Sets @code{$0}, @code{NF}, and @code{RT} @tab Standard -@item @var{command} @code{| getline} @var{var} @tab Sets @var{var} and @code{RT} @tab Standard -@item @var{command} @code{|& getline} @tab Sets @code{$0}, @code{NF}, and @code{RT} @tab Extension -@item @var{command} @code{|& getline} @var{var} @tab Sets @var{var} and @code{RT} @tab Extension +@headitem Variant @tab Effect @tab @command{awk} / @command{gawk} +@item @code{getline} @tab Sets @code{$0}, @code{NF}, @code{FNR}, @code{NR}, and @code{RT} @tab @command{awk} +@item @code{getline} @var{var} @tab Sets @var{var}, @code{FNR}, @code{NR}, and @code{RT} @tab @command{awk} +@item @code{getline <} @var{file} @tab Sets @code{$0}, @code{NF}, and @code{RT} @tab @command{awk} +@item @code{getline @var{var} < @var{file}} @tab Sets @var{var} and @code{RT} @tab @command{awk} +@item @var{command} @code{| getline} @tab Sets @code{$0}, @code{NF}, and @code{RT} @tab @command{awk} +@item @var{command} @code{| getline} @var{var} @tab Sets @var{var} and @code{RT} @tab @command{awk} +@item @var{command} @code{|& getline} @tab Sets @code{$0}, @code{NF}, and @code{RT} @tab @command{gawk} +@item @var{command} @code{|& getline} @var{var} @tab Sets @var{var} and @code{RT} @tab @command{gawk} @end multitable @end float @c ENDOFRANGE getl @@ -8538,7 +8549,7 @@ This @value{SECTION} describes a feature that is specific to @command{gawk}. You may specify a timeout in milliseconds for reading input from the keyboard, a pipe, or two-way communication, including TCP/IP sockets. This can be done on a per input, command or connection basis, by setting a special element -in the @code{PROCINFO} (@pxref{Auto-set}) array: +in the @code{PROCINFO} array (@pxref{Auto-set}): @example PROCINFO["input_name", "READ_TIMEOUT"] = @var{timeout in milliseconds} @@ -8570,7 +8581,7 @@ while ((getline < "/dev/stdin") > 0) @command{gawk} terminates the read operation if input does not arrive after waiting for the timeout period, returns failure -and sets the @code{ERRNO} variable to an appropriate string value. +and sets @code{ERRNO} to an appropriate string value. A negative or zero value for the timeout is the same as specifying no timeout at all. @@ -8677,6 +8688,10 @@ The possibilities are as follows: @end multitable @item +@code{FNR} indicates how many records have been read from the current input file; +@code{NR} indicates how many records have been read in total. + +@item @command{gawk} sets @code{RT} to the text matched by @code{RS}. @item @@ -8687,7 +8702,7 @@ fields there are. The default way to split fields is between whitespace characters. @item -Fields may be referenced using a variable, as in @samp{$NF}. Fields +Fields may be referenced using a variable, as in @code{$NF}. Fields may also be assigned values, which causes the value of @code{$0} to be recomputed when it is later referenced. Assigning to a field with a number greater than @code{NF} creates the field and rebuilds the record, using @@ -8697,16 +8712,17 @@ thing. Decrementing @code{NF} throws away fields and rebuilds the record. @item Field splitting is more complicated than record splitting. -@multitable @columnfractions .40 .40 .20 +@multitable @columnfractions .40 .45 .15 @headitem Field separator value @tab Fields are split @dots{} @tab @command{awk} / @command{gawk} @item @code{FS == " "} @tab On runs of whitespace @tab @command{awk} @item @code{FS == @var{any single character}} @tab On that character @tab @command{awk} @item @code{FS == @var{regexp}} @tab On text matching the regexp @tab @command{awk} @item @code{FS == ""} @tab Each individual character is a separate field @tab @command{gawk} @item @code{FIELDWIDTHS == @var{list of columns}} @tab Based on character position @tab @command{gawk} -@item @code{FPAT == @var{regexp}} @tab On text around text matching the regexp @tab @command{gawk} +@item @code{FPAT == @var{regexp}} @tab On the text surrounding text matching the regexp @tab @command{gawk} @end multitable +@item Using @samp{FS = "\n"} causes the entire record to be a single field (assuming that newlines separate records). @@ -8715,11 +8731,11 @@ Using @samp{FS = "\n"} causes the entire record to be a single field This can also be done using command-line variable assignment. @item -@code{PROCINFO["FS"]} can be used to see how fields are being split. +Use @code{PROCINFO["FS"]} to see how fields are being split. @item Use @code{getline} in its various forms to read additional records, -from the default input stream, from a file, or from a pipe or co-process. +from the default input stream, from a file, or from a pipe or coprocess. @item Use @code{PROCINFO[@var{file}, "READ_TIMEOUT"]} to cause reads to timeout @@ -8799,7 +8815,7 @@ and discusses the @code{close()} built-in function. @node Print @section The @code{print} Statement -The @code{print} statement is used for producing output with simple, standardized +Use the @code{print} statement to produce output with simple, standardized formatting. You specify only the strings or numbers to print, in a list separated by commas. They are output, separated by single spaces, followed by a newline. The statement looks like this: @@ -8823,7 +8839,7 @@ expression. Numeric values are converted to strings and then printed. @cindex text, printing The simple statement @samp{print} with no items is equivalent to @samp{print $0}: it prints the entire current record. To print a blank -line, use @samp{print ""}, where @code{""} is the empty string. +line, use @samp{print ""}. To print a fixed piece of text, use a string constant, such as @w{@code{"Don't Panic"}}, as one item. If you forget to use the double-quote characters, your text is taken as an @command{awk} @@ -8831,8 +8847,8 @@ expression, and you will probably get an error. Keep in mind that a space is printed between any two items. Note that the @code{print} statement is a statement and not an -expression---you can't use it the pattern part of a pattern-action -statement, for example. +expression---you can't use it in the pattern part of a +@var{pattern}-@var{action} statement, for example. @node Print Examples @section @code{print} Statement Examples @@ -8843,9 +8859,22 @@ newline, the newline is output along with the rest of the string. A single @code{print} statement can make any number of lines this way. @cindex newlines, printing -The following is an example of printing a string that contains embedded newlines +The following is an example of printing a string that contains embedded +@ifinfo +newlines +(the @samp{\n} is an escape sequence, used to represent the newline +character; @pxref{Escape Sequences}): +@end ifinfo +@ifhtml +newlines (the @samp{\n} is an escape sequence, used to represent the newline character; @pxref{Escape Sequences}): +@end ifhtml +@ifnotinfo +@ifnothtml +newlines: +@end ifnothtml +@end ifnotinfo @example $ @kbd{awk 'BEGIN @{ print "line one\nline two\nline three" @}'} @@ -9025,13 +9054,13 @@ more fully in @cindexawkfunc{sprintf} @cindex @code{OFMT} variable @cindex output, format specifier@comma{} @code{OFMT} -The built-in variable @code{OFMT} contains the default format specification +The built-in variable @code{OFMT} contains the format specification that @code{print} uses with @code{sprintf()} when it wants to convert a number to a string for printing. The default value of @code{OFMT} is @code{"%.6g"}. The way @code{print} prints numbers can be changed -by supplying different format specifications -as the value of @code{OFMT}, as shown in the following example: +by supplying a different format specification +for the value of @code{OFMT}, as shown in the following example: @example $ @kbd{awk 'BEGIN @{} @@ -9061,9 +9090,7 @@ With @code{printf} you can specify the width to use for each item, as well as various formatting choices for numbers (such as what output base to use, whether to print an exponent, whether to print a sign, and how many digits to print -after the decimal point). You do this by supplying a string, called -the @dfn{format string}, that controls how and where to print the other -arguments. +after the decimal point). @menu * Basic Printf:: Syntax of the @code{printf} statement. @@ -9083,10 +9110,10 @@ printf @var{format}, @var{item1}, @var{item2}, @dots{} @end example @noindent -The entire list of arguments may optionally be enclosed in parentheses. The -parentheses are necessary if any of the item expressions use the @samp{>} -relational operator; otherwise, it can be confused with an output redirection -(@pxref{Redirection}). +As print @code{print}, the entire list of arguments may optionally be +enclosed in parentheses. Here too, the parentheses are necessary if any +of the item expressions use the @samp{>} relational operator; otherwise, +it can be confused with an output redirection (@pxref{Redirection}). @cindex format specifiers The difference between @code{printf} and @code{print} is the @var{format} @@ -9109,10 +9136,10 @@ on @code{printf} statements. For example: @example $ @kbd{awk 'BEGIN @{} > @kbd{ORS = "\nOUCH!\n"; OFS = "+"} -> @kbd{msg = "Dont Panic!"} +> @kbd{msg = "Don\47t Panic!"} > @kbd{printf "%s\n", msg} > @kbd{@}'} -@print{} Dont Panic! +@print{} Don't Panic! @end example @noindent @@ -9134,7 +9161,7 @@ the field width. Here is a list of the format-control letters: @c @asis for docbook to come out right @table @asis @item @code{%c} -Print a number as an ASCII character; thus, @samp{printf "%c", +Print a number as a character; thus, @samp{printf "%c", 65} outputs the letter @samp{A}. The output for a string value is the first character of the string. @@ -9160,7 +9187,7 @@ a single byte (0--255). @item @code{%d}, @code{%i} Print a decimal integer. The two control letters are equivalent. -(The @samp{%i} specification is for compatibility with ISO C.) +(The @code{%i} specification is for compatibility with ISO C.) @item @code{%e}, @code{%E} Print a number in scientific (exponential) notation; @@ -9175,7 +9202,7 @@ prints @samp{1.950e+03}, with a total of four significant figures, three of which follow the decimal point. (The @samp{4.3} represents two modifiers, discussed in the next @value{SUBSECTION}.) -@samp{%E} uses @samp{E} instead of @samp{e} in the output. +@code{%E} uses @samp{E} instead of @samp{e} in the output. @item @code{%f} Print a number in floating-point notation. @@ -9201,16 +9228,16 @@ The special ``not a number'' value formats as @samp{-nan} or @samp{nan} (@pxref{Math Definitions}). @item @code{%F} -Like @samp{%f} but the infinity and ``not a number'' values are spelled +Like @code{%f} but the infinity and ``not a number'' values are spelled using uppercase letters. -The @samp{%F} format is a POSIX extension to ISO C; not all systems -support it. On those that don't, @command{gawk} uses @samp{%f} instead. +The @code{%F} format is a POSIX extension to ISO C; not all systems +support it. On those that don't, @command{gawk} uses @code{%f} instead. @item @code{%g}, @code{%G} Print a number in either scientific notation or in floating-point notation, whichever uses fewer characters; if the result is printed in -scientific notation, @samp{%G} uses @samp{E} instead of @samp{e}. +scientific notation, @code{%G} uses @samp{E} instead of @samp{e}. @item @code{%o} Print an unsigned octal integer @@ -9226,7 +9253,7 @@ are floating-point; it is provided primarily for compatibility with C.) @item @code{%x}, @code{%X} Print an unsigned hexadecimal integer; -@samp{%X} uses the letters @samp{A} through @samp{F} +@code{%X} uses the letters @samp{A} through @samp{F} instead of @samp{a} through @samp{f} (@pxref{Nondecimal-numbers}). @@ -9241,7 +9268,7 @@ argument and it ignores any modifiers. @quotation NOTE When using the integer format-control letters for values that are outside the range of the widest C integer type, @command{gawk} switches to -the @samp{%g} format specifier. If @option{--lint} is provided on the +the @code{%g} format specifier. If @option{--lint} is provided on the command line (@pxref{Options}), @command{gawk} warns about this. Other versions of @command{awk} may print invalid values or do something else entirely. @@ -9257,7 +9284,7 @@ values or do something else entirely. A format specification can also include @dfn{modifiers} that can control how much of the item's value is printed, as well as how much space it gets. The modifiers come between the @samp{%} and the format-control letter. -We will use the bullet symbol ``@bullet{}'' in the following examples to +We use the bullet symbol ``@bullet{}'' in the following examples to represent spaces in the output. Here are the possible modifiers, in the order in which they may appear: @@ -9288,7 +9315,7 @@ It is in fact a @command{gawk} extension, intended for use in translating messages at runtime. @xref{Printf Ordering}, which describes how and why to use positional specifiers. -For now, we will not use them. +For now, we ignore them. @item - The minus sign, used before the width modifier (see later on in @@ -9316,15 +9343,15 @@ to format is positive. The @samp{+} overrides the space modifier. @item # Use an ``alternate form'' for certain control letters. -For @samp{%o}, supply a leading zero. -For @samp{%x} and @samp{%X}, supply a leading @samp{0x} or @samp{0X} for +For @code{%o}, supply a leading zero. +For @code{%x} and @code{%X}, supply a leading @code{0x} or @samp{0X} for a nonzero result. -For @samp{%e}, @samp{%E}, @samp{%f}, and @samp{%F}, the result always +For @code{%e}, @code{%E}, @code{%f}, and @code{%F}, the result always contains a decimal point. -For @samp{%g} and @samp{%G}, trailing zeros are not removed from the result. +For @code{%g} and @code{%G}, trailing zeros are not removed from the result. @item 0 -A leading @samp{0} (zero) acts as a flag that indicates that output should be +A leading @samp{0} (zero) acts as a flag indicating that output should be padded with zeros instead of spaces. This applies only to the numeric output formats. This flag only has an effect when the field width is wider than the @@ -9510,7 +9537,7 @@ the @command{awk} program: @example awk 'BEGIN @{ print "Name Number" print "---- ------" @} - @{ printf "%-10s %s\n", $1, $2 @}' mail-list + @{ printf "%-10s %s\n", $1, $2 @}' mail-list @end example The above example mixes @code{print} and @code{printf} statements in @@ -9520,7 +9547,7 @@ same results: @example awk 'BEGIN @{ printf "%-10s %s\n", "Name", "Number" printf "%-10s %s\n", "----", "------" @} - @{ printf "%-10s %s\n", $1, $2 @}' mail-list + @{ printf "%-10s %s\n", $1, $2 @}' mail-list @end example @noindent @@ -9535,7 +9562,7 @@ emphasized by storing it in a variable, like this: awk 'BEGIN @{ format = "%-10s %s\n" printf format, "Name", "Number" printf format, "----", "------" @} - @{ printf format, $1, $2 @}' mail-list + @{ printf format, $1, $2 @}' mail-list @end example @c ENDOFRANGE printfs @@ -9556,7 +9583,7 @@ This is called @dfn{redirection}. @quotation NOTE When @option{--sandbox} is specified (@pxref{Options}), -redirecting output to files and pipes is disabled. +redirecting output to files, pipes and coprocesses is disabled. @end quotation A redirection appears after the @code{print} or @code{printf} statement. @@ -9653,17 +9680,11 @@ in an @command{awk} script run periodically for system maintenance: @example report = "mail bug-system" -print "Awk script failed:", $0 | report -m = ("at record number " FNR " of " FILENAME) -print m | report +print("Awk script failed:", $0) | report +print("at record number", FNR, "of", FILENAME) | report close(report) @end example -The message is built using string concatenation and saved in the variable -@code{m}. It's then sent down the pipeline to the @command{mail} program. -(The parentheses group the items to concatenate---see -@ref{Concatenation}.) - The @code{close()} function is called here because it's a good idea to close the pipe as soon as all the intended output has been sent to it. @xref{Close Files And Pipes}, @@ -9812,7 +9833,7 @@ It then sends the list to the shell for execution. @cindex @command{gawk}, file names in @command{gawk} provides a number of special @value{FN}s that it interprets -internally. These @value{FN}s provide access to standard file descriptors +internally. These @value{FN}s provide access to standard pre-opened files and TCP/IP networking. @menu @@ -9822,7 +9843,7 @@ and TCP/IP networking. @end menu @node Special FD -@subsection Special Files for Standard Descriptors +@subsection Special Files for Standard Pre-Opened Files @cindex standard input @cindex input, standard @cindex standard output @@ -9870,7 +9891,7 @@ that is connected to your keyboard and screen. It represents the ``terminal,''@footnote{The ``tty'' in @file{/dev/tty} stands for ``Teletype,'' a serial terminal.} which on modern systems is a keyboard and screen, not a serial console.) -This usually has the same effect but not always: although the +This generally has the same effect but not always: although the standard error stream is usually the screen, it can be redirected; when that happens, writing to the screen is not correct. In fact, if @command{awk} is run from a background job, it may not have a @@ -9879,9 +9900,12 @@ Then opening @file{/dev/tty} fails. @command{gawk} provides special @value{FN}s for accessing the three standard streams. @value{COMMONEXT} It also provides syntax for accessing -any other inherited open files. If the @value{FN} matches +any other inherited open files. +These open files are often referred to by the technical term +@dfn{file descriptor}. +If the @value{FN} matches one of these special names when @command{gawk} redirects input or output, -then it directly uses the stream that the @value{FN} stands for. +then it directly uses the descriptor that the @value{FN} stands for. These special @value{FN}s work for all operating systems that @command{gawk} has been ported to, not just those that are POSIX-compliant: @@ -9964,7 +9988,7 @@ Full discussion is delayed until @node Special Caveats @subsection Special @value{FFN} Caveats -Here is a list of things to bear in mind when using the +Here are some things to bear in mind when using the special @value{FN}s that @command{gawk} provides: @itemize @value{BULLET} @@ -10142,7 +10166,8 @@ to a string indicating the error. Note also that @samp{close(FILENAME)} has no ``magic'' effects on the implicit loop that reads through the files named on the command line. It is, more likely, a close of a file that was never opened with a -redirection, so @command{awk} silently does nothing. +redirection, so @command{awk} silently does nothing, except return +a negative value. @cindex @code{|} (vertical bar), @code{|&} operator (I/O), pipes@comma{} closing When using the @samp{|&} operator to communicate with a coprocess, @@ -10154,10 +10179,10 @@ the first argument is the name of the command or special file used to start the coprocess. The second argument should be a string, with either of the values @code{"to"} or @code{"from"}. Case does not matter. -As this is an advanced feature, a more complete discussion is +As this is an advanced feature, discussion is delayed until @ref{Two-way I/O}, -which discusses it in more detail and gives an example. +which describes it in more detail and gives an example. @cindex sidebar, Using @code{close()}'s Return Value @ifdocbook @@ -10291,15 +10316,15 @@ that modify the behavior of the format control letters. @item Output from both @code{print} and @code{printf} may be redirected to -files, pipes, and co-processes. +files, pipes, and coprocesses. @item @command{gawk} provides special file names for access to standard input, output and error, and for network communications. @item -Use @code{close()} to close open file, pipe and co-process redirections. -For co-processes, it is possible to close only one direction of the +Use @code{close()} to close open file, pipe and coprocess redirections. +For coprocesses, it is possible to close only one direction of the communications. @end itemize @@ -12144,7 +12169,7 @@ so similar, this kind of error is very difficult to spot when scanning the source code. @cindex @command{gawk}, comparison operators and -The following table of expressions illustrates the kind of comparison +The following list of expressions illustrates the kind of comparison @command{gawk} performs, as well as what the result of the comparison is: @table @code @@ -12635,7 +12660,7 @@ expression because the first @samp{$} has higher precedence than the @samp{++}; to avoid the problem the expression can be rewritten as @samp{$($0++)--}. -This table presents @command{awk}'s operators, in order of highest +This list presents @command{awk}'s operators, in order of highest to lowest precedence: @c @asis for docbook to come out right @@ -12805,7 +12830,7 @@ character}, to find the record terminator. Locales can affect how dates and times are formatted (@pxref{Time Functions}). For example, a common way to abbreviate the date September 4, 2015 in the United States is ``9/4/15.'' In many countries in -Europe, however, it is abbreviated ``4.9.15.'' Thus, the @samp{%x} +Europe, however, it is abbreviated ``4.9.15.'' Thus, the @code{%x} specification in a @code{"US"} locale might produce @samp{9/4/15}, while in a @code{"EUROPE"} locale, it might produce @samp{4.9.15}. @@ -18538,7 +18563,7 @@ of its ISO week number is 2013, even though its year is 2012. The full year of the ISO week number, as a decimal number. @item %h -Equivalent to @samp{%b}. +Equivalent to @code{%b}. @item %H The hour (24-hour clock) as a decimal number (00--23). @@ -18607,7 +18632,7 @@ The locale's ``appropriate'' date representation. @item %X The locale's ``appropriate'' time representation. -(This is @samp{%T} in the @code{"C"} locale.) +(This is @code{%T} in the @code{"C"} locale.) @item %y The year modulo 100 as a decimal number (00--99). @@ -18628,7 +18653,7 @@ no time zone is determinable. @item %Ec %EC %Ex %EX %Ey %EY %Od %Oe %OH @itemx %OI %Om %OM %OS %Ou %OU %OV %Ow %OW %Oy ``Alternate representations'' for the specifications -that use only the second letter (@samp{%c}, @samp{%C}, +that use only the second letter (@code{%c}, @code{%C}, and so on).@footnote{If you don't understand any of this, don't worry about it; these facilities are meant to make it easier to ``internationalize'' programs. @@ -18891,7 +18916,7 @@ For example, if you have a bit string @samp{10111001} and you shift it right by three bits, you end up with @samp{00010111}.@footnote{This example shows that 0's come in on the left side. For @command{gawk}, this is always true, but in some languages, it's possible to have the left side -fill with 1's. Caveat emptor.} +fill with 1's.} @c Purposely decided to use 0's and 1's here. 2/2001. If you start over again with @samp{10111001} and shift it left by three bits, you end up @@ -19967,7 +19992,7 @@ saving it in @code{start}. The last part of the code loops through each function name (from @code{$2} up to the marker, @samp{data:}), calling the function named by the field. The indirect function call itself occurs as a parameter in the call to @code{printf}. -(The @code{printf} format string uses @samp{%s} as the format specifier so that we +(The @code{printf} format string uses @code{%s} as the format specifier so that we can use functions that return strings, as well as numbers. Note that the result from the indirect call is concatenated with the empty string, in order to force it to be a string value.) @@ -25876,8 +25901,8 @@ the path, and an attempt is made to open the generated @value{FN}. The only way to test if a file can be read in @command{awk} is to go ahead and try to read it with @code{getline}; this is what @code{pathto()} does.@footnote{On some very old versions of @command{awk}, the test -@samp{getline junk < t} can loop forever if the file exists but is empty. -Caveat emptor.} If the file can be read, it is closed and the @value{FN} +@samp{getline junk < t} can loop forever if the file exists but is empty.} +If the file can be read, it is closed and the @value{FN} is returned: @ignore @@ -27057,7 +27082,6 @@ come into play; comparisons are based on character values only.@footnote{This is true because locale-based comparison occurs only when in POSIX compatibility mode, and since @code{asort()} and @code{asorti()} are @command{gawk} extensions, they are not available in that case.} -Caveat Emptor. @node Two-way I/O @section Two-Way Communications with Another Process @@ -27708,9 +27732,9 @@ those functions sort arrays. Or you may provide one of the predefined control strings that work for @code{PROCINFO["sorted_in"]}. @item -You can use the @samp{|&} operator to create a two-way pipe to a co-process. -You read from the co-process with @code{getline} and write to it with @code{print} -or @code{printf}. Use @code{close()} to close off the co-process completely, or +You can use the @samp{|&} operator to create a two-way pipe to a coprocess. +You read from the coprocess with @code{getline} and write to it with @code{print} +or @code{printf}. Use @code{close()} to close off the coprocess completely, or optionally, close off one side of the two-way communications. @item @@ -35111,7 +35135,7 @@ for case translation (@pxref{String Functions}). @item -A cleaner specification for the @samp{%c} format-control letter in the +A cleaner specification for the @code{%c} format-control letter in the @code{printf} function (@pxref{Control Letters}). @@ -37510,7 +37534,7 @@ need to use the @code{BINMODE} variable. This can cause problems with other Unix-like components that have been ported to MS-Windows that expect @command{gawk} to do automatic -translation of @code{"\r\n"}, since it won't. Caveat Emptor! +translation of @code{"\r\n"}, since it won't. @node VMS Installation @appendixsubsec How to Compile and Install @command{gawk} on Vax/VMS and OpenVMS @@ -41516,6 +41540,7 @@ Consistency issues: Use --foo, not -Wfoo when describing long options Use "Bell Laboratories", but not "Bell Labs". Use "behavior" instead of "behaviour". + Use "coprocess" instead of "co-process". Use "zeros" instead of "zeroes". Use "nonzero" not "non-zero". Use "runtime" not "run time" or "run-time". diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 2f6eb42c..dfc710b5 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -48,11 +48,16 @@ @c applies to and all the info about who's publishing this edition @c These apply across the board. -@set UPDATE-MONTH August, 2014 +@set UPDATE-MONTH September, 2014 @set VERSION 4.1 -@set PATCHLEVEL 1 +@set PATCHLEVEL 2 +@ifset FOR_PRINT +@set TITLE Effective AWK Programming +@end ifset +@ifclear FOR_PRINT @set TITLE GAWK: Effective AWK Programming +@end ifclear @set SUBTITLE A User's Guide for GNU Awk @set EDITION 4.1 @@ -1083,7 +1088,7 @@ books on Unix, I found the gray AWK book, a.k.a.@: Aho, Kernighan and Weinberger, @cite{The AWK Programming Language}, Addison-Wesley, 1988. AWK's simple programming paradigm---find a pattern in the input and then perform an action---often reduced complex or tedious -data manipulations to few lines of code. I was excited to try my +data manipulations to a few lines of code. I was excited to try my hand at programming in AWK. Alas, the @command{awk} on my computer was a limited version of the @@ -1217,7 +1222,7 @@ March, 2001 <affiliation><jobtitle>Nof Ayalon</jobtitle></affiliation> <affiliation><jobtitle>ISRAEL</jobtitle></affiliation> </author> - <date>June, 2014</date> + <date>December, 2014</date> </prefaceinfo> @end docbook @@ -1239,7 +1244,7 @@ and with the Unix version of @command{awk} maintained by Brian Kernighan. This means that all properly written @command{awk} programs should work with @command{gawk}. -Thus, we usually don't distinguish between @command{gawk} and other +So most of the time, we don't distinguish between @command{gawk} and other @command{awk} implementations. @cindex @command{awk}, POSIX and, See Also POSIX @command{awk} @@ -1286,15 +1291,15 @@ Sort data Perform simple network communications @item -Profile and debug @command{awk} programs. +Profile and debug @command{awk} programs @item -Extend the language with functions written in C or C++. +Extend the language with functions written in C or C++ @end itemize This @value{DOCUMENT} teaches you about the @command{awk} language and how you can use it effectively. You should already be familiar with basic -system commands, such as @command{cat} and @command{ls},@footnote{These commands +system commands, such as @command{cat} and @command{ls},@footnote{These utilities are available on POSIX-compliant systems, as well as on traditional Unix-based systems. If you are using some other operating system, you still need to be familiar with the ideas of I/O redirection and pipes.} as well as basic shell @@ -1316,10 +1321,9 @@ Microsoft Windows @ifclear FOR_PRINT (all versions) and OS/2 PCs, @end ifclear -and OpenVMS. -(Some other, obsolete systems to which @command{gawk} was once ported -are no longer supported and the code for those systems -has been removed.) +and OpenVMS.@footnote{Some other, obsolete systems to which @command{gawk} +was once ported are no longer supported and the code for those systems +has been removed.} @menu * History:: The history of @command{gawk} and @@ -1483,7 +1487,7 @@ All appear in the index, under the heading ``sidebar.'' Most of the time, the examples use complete @command{awk} programs. Some of the more advanced sections show only the part of the @command{awk} -program that illustrates the concept currently being described. +program that illustrates the concept being described. While this @value{DOCUMENT} is aimed principally at people who have not been exposed @@ -1541,9 +1545,9 @@ sorting arrays in @command{gawk}. It also describes how @command{gawk} provides arrays of arrays. @ref{Functions}, -describes the built-in functions @command{awk} and -@command{gawk} provide, as well as how to define -your own functions. +describes the built-in functions @command{awk} and @command{gawk} provide, +as well as how to define your own functions. It also discusses how +@command{gawk} lets you call functions indirectly. Part II shows how to use @command{awk} and @command{gawk} for problem solving. There is lots of code here for you to read and learn from. @@ -1616,9 +1620,10 @@ printed edition. You may find them online, as follows: @uref{http://www.gnu.org/software/gawk/manual/html_node/Notes.html, The appendix on implementation notes} -describes how to disable @command{gawk}'s extensions, as -well as how to contribute new code to @command{gawk}, -and some possible future directions for @command{gawk} development. +describes how to disable @command{gawk}'s extensions, how to contribute +new code to @command{gawk}, where to find information on some possible +future directions for @command{gawk} development, and the design decisions +behind the extension API. @uref{http://www.gnu.org/software/gawk/manual/html_node/Basic-Concepts.html, The appendix on basic concepts} @@ -1636,7 +1641,7 @@ The GNU FDL} is the license that covers this @value{DOCUMENT}. Some of the chapters have exercise sections; these have also been -omitted from the print edition. +omitted from the print edition but are available online. @end ifset @ifclear FOR_PRINT @@ -1859,7 +1864,7 @@ The FSF published the first two editions under the title @cite{The GNU Awk User's Guide}. @ifset FOR_PRINT SSC published two editions of the @value{DOCUMENT} under the -title @cite{Effective awk Programming}, and in O'Reilly published +title @cite{Effective awk Programming}, and O'Reilly published the third edition in 2001. @end ifset @@ -1891,7 +1896,7 @@ for information on submitting problem reports electronically. @unnumberedsec How to Stay Current It may be you have a version of @command{gawk} which is newer than the -one described in this @value{DOCUMENT}. To find out what has changed, +one described here. To find out what has changed, you should first look at the @file{NEWS} file in the @command{gawk} distribution, which provides a high level summary of what changed in each release. @@ -2113,7 +2118,7 @@ take advantage of those opportunities. Arnold Robbins @* Nof Ayalon @* ISRAEL @* -May, 2014 +December, 2014 @end iftex @ifnotinfo @@ -2332,7 +2337,7 @@ to keep you from worrying about the complexities of computer programming: @example -$ @kbd{awk "BEGIN @{ print "Don\47t Panic!" @}"} +$ @kbd{awk 'BEGIN @{ print "Don\47t Panic!" @}'} @print{} Don't Panic! @end example @@ -2340,11 +2345,11 @@ $ @kbd{awk "BEGIN @{ print "Don\47t Panic!" @}"} reading any input. If there are no other statements in your program, as is the case here, @command{awk} just stops, instead of trying to read input it doesn't know how to process. -The @samp{\47} is a magic way of getting a single quote into +The @samp{\47} is a magic way (explained later) of getting a single quote into the program, without having to engage in ugly shell quoting tricks. @quotation NOTE -As a side note, if you use Bash as your shell, you should execute the +If you use Bash as your shell, you should execute the command @samp{set +H} before running this program interactively, to disable the C shell-style command history, which treats @samp{!} as a special character. We recommend putting this command into your personal @@ -2374,7 +2379,7 @@ $ @kbd{awk '@{ print @}'} @cindex @command{awk} programs, running @cindex @command{awk} programs, lengthy @cindex files, @command{awk} programs in -Sometimes your @command{awk} programs can be very long. In this case, it is +Sometimes @command{awk} programs are very long. In these cases, it is more convenient to put the program into a separate file. In order to tell @command{awk} to use that file for its program, you type: @@ -2404,7 +2409,7 @@ awk -f advice does the same thing as this one: @example -awk "BEGIN @{ print \"Don't Panic!\" @}" +awk 'BEGIN @{ print "Don\47t Panic!" @}' @end example @cindex quoting in @command{gawk} command lines @@ -2416,6 +2421,8 @@ specify with @option{-f}, because most @value{FN}s don't contain any of the shel special characters. Notice that in @file{advice}, the @command{awk} program did not have single quotes around it. The quotes are only needed for programs that are provided on the @command{awk} command line. +(Also, placing the program in a file allows us to use a literal single quote in the program +text, instead of the magic @samp{\47}.) @c STARTOFRANGE sq1x @cindex single quote (@code{'}) in @command{gawk} command lines @@ -2474,7 +2481,7 @@ written in @command{awk}. according to the instructions in your program. (This is different from a @dfn{compiled} language such as C, where your program is first compiled into machine code that is executed directly by your system's -hardware.) The @command{awk} utility is thus termed an @dfn{interpreter}. +processor.) The @command{awk} utility is thus termed an @dfn{interpreter}. Many modern languages are interperted. The line beginning with @samp{#!} lists the full @value{FN} of an @@ -2483,9 +2490,9 @@ to pass to that interpreter. The operating system then runs the interpreter with the given argument and the full argument list of the executed program. The first argument in the list is the full @value{FN} of the @command{awk} program. The rest of the argument list contains -either options to @command{awk}, or @value{DF}s, or both. Note that on +either options to @command{awk}, or @value{DF}s, or both. (Note that on many systems @command{awk} may be found in @file{/usr/bin} instead of -in @file{/bin}. Caveat Emptor. +in @file{/bin}.) Some systems limit the length of the interpreter name to 32 characters. Often, this can be dealt with by using a symbolic link. @@ -2663,8 +2670,14 @@ Thus, the example seen @ifnotinfo previously @end ifnotinfo -in @ref{Read Terminal}, -is applicable: +in @ref{Read Terminal}: + +@example +awk 'BEGIN @{ print "Don\47t Panic!" @}' +@end example + +@noindent +could instead be written this way: @example $ @kbd{awk "BEGIN @{ print \"Don't Panic!\" @}"} @@ -2759,6 +2772,9 @@ $ awk -v sq="'" 'BEGIN @{ print "Here is a single quote <" sq ">" @}' @print{} Here is a single quote <'> @end example +(Here, the two string constants and the value of @code{sq} are concatenated +into a single string which is printed by @code{print}.) + If you really need both single and double quotes in your @command{awk} program, it is probably best to move it into a separate file, where the shell won't be part of the picture, and you can say what you mean. @@ -2822,7 +2838,7 @@ The second @value{DF}, called @file{inventory-shipped}, contains information about monthly shipments. In both files, each line is considered to be one @dfn{record}. -In the @value{DF} @file{mail-list}, each record contains the name of a person, +In @file{mail-list}, each record contains the name of a person, his/her phone number, his/her email-address, and a code for their relationship with the author of the list. The columns are aligned using spaces. @@ -2982,7 +2998,7 @@ Print the length of the longest line in @file{data}: @example expand data | awk '@{ if (x < length($0)) x = length($0) @} - END @{ print "maximum line length is " x @}' + END @{ print "maximum line length is " x @}' @end example This example differs slightly from the previous one: @@ -3014,7 +3030,7 @@ Print the total number of bytes used by @var{files}: @example ls -l @var{files} | awk '@{ x += $5 @} - END @{ print "total bytes: " x @}' + END @{ print "total bytes: " x @}' @end example @item @@ -3058,7 +3074,7 @@ the program would print the odd-numbered lines. @cindex @command{awk} programs The @command{awk} utility reads the input files one line at a -time. For each line, @command{awk} tries the patterns of each of the rules. +time. For each line, @command{awk} tries the patterns of each rule. If several patterns match, then several actions execute in the order in which they appear in the @command{awk} program. If no patterns match, then no actions run. @@ -3066,7 +3082,7 @@ no actions run. After processing all the rules that match the line (and perhaps there are none), @command{awk} reads the next line. (However, @pxref{Next Statement}, -and also @pxref{Nextfile Statement}). +and also @pxref{Nextfile Statement}.) This continues until the program reaches the end of the file. For example, the following @command{awk} program contains two rules: @@ -3140,13 +3156,12 @@ the file was last modified. Its output looks like this: @noindent @cindex line continuations, with C shell The first field contains read-write permissions, the second field contains -the number of links to the file, and the third field identifies the owner of -the file. The fourth field identifies the group of the file. -The fifth field contains the size of the file in bytes. The +the number of links to the file, and the third field identifies the file's owner. +The fourth field identifies the file's group. +The fifth field contains the file's size in bytes. The sixth, seventh, and eighth fields contain the month, day, and time, respectively, that the file was last modified. Finally, the ninth field -contains the @value{FN}.@footnote{The @samp{LC_ALL=C} is -needed to produce this traditional-style output from @command{ls}.} +contains the @value{FN}. @c @cindex automatic initialization @cindex initialization, automatic @@ -3556,7 +3571,7 @@ more than once, setting another variable each time, like this: Using @option{-v} to set the values of the built-in variables may lead to surprising results. @command{awk} will reset the values of those variables as it needs to, possibly ignoring any -predefined value you may have given. +initial value you may have given. @end quotation @item -W @var{gawk-opt} @@ -3639,7 +3654,7 @@ Print the short version of the General Public License and then exit. @cindex variables, global, printing list of Print a sorted list of global variables, their types, and final values to @var{file}. If no @var{file} is provided, print this -list to the file named @file{awkvars.out} in the current directory. +list to a file named @file{awkvars.out} in the current directory. No space is allowed between the @option{-d} and @var{file}, if @var{file} is supplied. @@ -3735,7 +3750,7 @@ that @command{gawk} accepts and then exit. @cindex @option{-i} option @cindex @option{--include} option @cindex @command{awk} programs, location of -Read @command{awk} source library from @var{source-file}. This option +Read an @command{awk} source library from @var{source-file}. This option is completely equivalent to using the @code{@@include} directive inside your program. This option is very similar to the @option{-f} option, but there are two important differences. First, when @option{-i} is @@ -3759,7 +3774,7 @@ environment variable. The correct library suffix for your platform will be supplied by default, so it need not be specified in the extension name. The extension initialization routine should be named @code{dl_load()}. An alternative is to use the @code{@@load} keyword inside the program to load -a shared library. This feature is described in detail in @ref{Dynamic Extensions}. +a shared library. This advanced feature is described in detail in @ref{Dynamic Extensions}. @item @option{-L}[@var{value}] @itemx @option{--lint}[@code{=}@var{value}] @@ -3973,6 +3988,7 @@ if they had been concatenated together into one big file. This is useful for creating libraries of @command{awk} functions. These functions can be written once and then retrieved from a standard place, instead of having to be included into each individual program. +The @option{-i} option is similar in this regard. (As mentioned in @ref{Definition Syntax}, function names must be unique.) @@ -4046,15 +4062,18 @@ Any additional arguments on the command line are normally treated as input files to be processed in the order specified. However, an argument that has the form @code{@var{var}=@var{value}}, assigns the value @var{value} to the variable @var{var}---it does not specify a -file at all. -(See -@ref{Assignment Options}.) +file at all. (See @ref{Assignment Options}.) In the following example, +@var{count=1} is a variable assignment, not a @value{FN}: + +@example +awk -f program.awk file1 count=1 file2 +@end example @cindex @command{gawk}, @code{ARGIND} variable in @cindex @code{ARGIND} variable, command-line arguments @cindex @code{ARGV} array, indexing into @cindex @code{ARGC}/@code{ARGV} variables, command-line arguments -All these arguments are made available to your @command{awk} program in the +All the command-line arguments are made available to your @command{awk} program in the @code{ARGV} array (@pxref{Built-in Variables}). Command-line options and the program text (if present) are omitted from @code{ARGV}. All other arguments, including variable assignments, are @@ -4185,15 +4204,15 @@ separated by colons@footnote{Semicolons on MS-Windows and MS-DOS.}. @command{ga @samp{.:/usr/local/share/awk}.@footnote{Your version of @command{gawk} may use a different directory; it will depend upon how @command{gawk} was built and installed. The actual -directory is the value of @samp{$(datadir)} generated when +directory is the value of @code{$(datadir)} generated when @command{gawk} was configured. You probably don't need to worry about this, though.} The search path feature is particularly helpful for building libraries of useful @command{awk} functions. The library files can be placed in a standard directory in the default path and then specified on -the command line with a short @value{FN}. Otherwise, the full @value{FN} -would have to be typed for each file. +the command line with a short @value{FN}. Otherwise, you would have to +type the full @value{FN} for each file. By using the @option{-i} option, or the @option{-e} and @option{-f} options, your command-line @command{awk} programs can use facilities in @command{awk} library files @@ -4202,25 +4221,23 @@ Path searching is not done if @command{gawk} is in compatibility mode. This is true for both @option{--traditional} and @option{--posix}. @xref{Options}. -If the source code is not found after the initial search, the path is searched +If the source code file is not found after the initial search, the path is searched again after adding the default @samp{.awk} suffix to the @value{FN}. -@quotation NOTE -@c 4/2014: -@c using @samp{.} to get quotes, since @file{} no longer supplies them. -To include -the current directory in the path, either place -@samp{.} explicitly in the path or write a null entry in the -path. (A null entry is indicated by starting or ending the path with a -colon or by placing two colons next to each other [@samp{::}].) -This path search mechanism is similar +@command{gawk}'s path search mechanism is similar to the shell's. (See @uref{http://www.gnu.org/software/bash/manual/, -@cite{The Bourne-Again SHell manual}.}) +@cite{The Bourne-Again SHell manual}}.) +It treats a null entry in the path as indicating the current +directory. +(A null entry is indicated by starting or ending the path with a +colon or by placing two colons next to each other [@samp{::}].) -However, @command{gawk} always looks in the current directory @emph{before} -searching @env{AWKPATH}, so there is no real reason to include -the current directory in the search path. +@quotation NOTE +@command{gawk} always looks in the current directory @emph{before} +searching @env{AWKPATH}. Thus, while you can include the current directory +in the search path, either explicitly or with a null entry, there is no +real reason to do so. @c Prior to 4.0, gawk searched the current directory after the @c path search, but it's not worth documenting it. @end quotation @@ -4261,16 +4278,6 @@ behavior, but they are more specialized. Those in the following list are meant to be used by regular users. @table @env -@item POSIXLY_CORRECT -Causes @command{gawk} to switch to POSIX compatibility -mode, disabling all traditional and GNU extensions. -@xref{Options}. - -@item GAWK_SOCK_RETRIES -Controls the number of times @command{gawk} attempts to -retry a two-way TCP/IP (socket) connection before giving up. -@xref{TCP/IP Networking}. - @item GAWK_MSEC_SLEEP Specifies the interval between connection retries, in milliseconds. On systems that do not support @@ -4281,6 +4288,16 @@ the value is rounded up to an integral number of seconds. Specifies the time, in milliseconds, for @command{gawk} to wait for input before returning with an error. @xref{Read Timeout}. + +@item GAWK_SOCK_RETRIES +Controls the number of times @command{gawk} attempts to +retry a two-way TCP/IP (socket) connection before giving up. +@xref{TCP/IP Networking}. + +@item POSIXLY_CORRECT +Causes @command{gawk} to switch to POSIX compatibility +mode, disabling all traditional and GNU extensions. +@xref{Options}. @end table The environment variables in the following list are meant @@ -4295,7 +4312,7 @@ file as the size of the memory buffer to allocate for I/O. Otherwise, the value should be a number, and @command{gawk} uses that number as the size of the buffer to allocate. (When this variable is not set, @command{gawk} uses the smaller of the file's size and the ``default'' -blocksize, which is usually the filesystems I/O blocksize.) +blocksize, which is usually the filesystem's I/O blocksize.) @item AWK_HASH If this variable exists with a value of @samp{gst}, @command{gawk} @@ -4310,10 +4327,11 @@ for debugging problems on filesystems on non-POSIX operating systems where I/O is performed in records, not in blocks. @item GAWK_MSG_SRC -If this variable exists, @command{gawk} includes the source file -name and line number from which warning and/or fatal messages +If this variable exists, @command{gawk} includes the file +name and line number within the @command{gawk} source code +from which warning and/or fatal messages are generated. Its purpose is to help isolate the source of a -message, since there can be multiple places which produce the +message, since there are multiple places which produce the same warning or error message. @item GAWK_NO_DFA @@ -4326,8 +4344,11 @@ coordinate with each other.) @item GAWK_NO_PP_RUN If this variable exists, then when invoked with the @option{--pretty-print} -option, @command{gawk} skips running the program. This variable will -not survive into the next major release. +option, @command{gawk} skips running the program. + +@quotation CAUTION +This variable will not survive into the next major release. +@end quotation @item GAWK_STACKSIZE This specifies the amount by which @command{gawk} should grow its @@ -4531,6 +4552,7 @@ that requires access to an extension. @ref{Dynamic Extensions}, describes how to write extensions (in C or C++) that can be loaded with either @code{@@load} or the @option{-l} option. +It also describes the @code{ordchr} extension. @node Obsolete @section Obsolete Options and/or Features @@ -4599,15 +4621,15 @@ awk '@{ sum += $1 @} END @{ print sum @}' @end example @command{gawk} actually supports this but it is purposely undocumented -because it is considered bad style. The correct way to write such a program -is either +because it is bad style. The correct way to write such a program +is either: @example awk '@{ sum += $1 @} ; END @{ print sum @}' @end example @noindent -or +or: @example awk '@{ sum += $1 @} @@ -4615,8 +4637,7 @@ awk '@{ sum += $1 @} @end example @noindent -@xref{Statements/Lines}, for a fuller -explanation. +@xref{Statements/Lines}, for a fuller explanation. You can insert newlines after the @samp{;} in @code{for} loops. This seems to have been a long-undocumented feature in Unix @command{awk}. @@ -4656,7 +4677,8 @@ affects how @command{awk} processes input. @item You can use a single minus sign (@samp{-}) to refer to standard input -on the command line. +on the command line. @command{gawk} also lets you use the special +@value{FN} @file{/dev/stdin}. @item @command{gawk} pays attention to a number of environment variables. @@ -4845,7 +4867,7 @@ such as TAB or newline. While there is nothing to stop you from entering most unprintable characters directly in a string constant or regexp constant, they may look ugly. -The following table lists +The following list presents all the escape sequences used in @command{awk} and what they represent. Unless noted otherwise, all these escape sequences apply to both string constants and regexp constants: @@ -4960,13 +4982,13 @@ characters @samp{a+b}. @cindex @code{\} (backslash), in escape sequences @cindex portability For complete portability, do not use a backslash before any character not -shown in the previous list. +shown in the previous list and that is not an operator. To summarize: @itemize @value{BULLET} @item -The escape sequences in the table above are always processed first, +The escape sequences in the list above are always processed first, for both string constants and regexp constants. This happens very early, as soon as @command{awk} reads your program. @@ -5056,7 +5078,7 @@ are recognized and converted into corresponding real characters as the very first step in processing regexps. Here is a list of metacharacters. All characters that are not escape -sequences and that are not listed in the table stand for themselves: +sequences and that are not listed in the following stand for themselves: @c Use @asis so the docbook comes out ok. Sigh. @table @asis @@ -5313,7 +5335,7 @@ characters to be matched. @cindex Extended Regular Expressions (EREs) @cindex EREs (Extended Regular Expressions) @cindex @command{egrep} utility -This treatment of @samp{\} in bracket expressions +The treatment of @samp{\} in bracket expressions is compatible with other @command{awk} implementations and is also mandated by POSIX. The regular expressions in @command{awk} are a superset @@ -5430,11 +5452,11 @@ Consider the following: echo aaaabcd | awk '@{ sub(/a+/, "<A>"); print @}' @end example -This example uses the @code{sub()} function (which we haven't discussed yet; -@pxref{String Functions}) -to make a change to the input record. Here, the regexp @code{/a+/} -indicates ``one or more @samp{a} characters,'' and the replacement -text is @samp{<A>}. +This example uses the @code{sub()} function to make a change to the input +record. (@code{sub()} replaces the first instance of any text matched +by the first argument with the string provided as the second argument; +@pxref{String Functions}). Here, the regexp @code{/a+/} indicates ``one +or more @samp{a} characters,'' and the replacement text is @samp{<A>}. The input contains four @samp{a} characters. @command{awk} (and POSIX) regular expressions always match @@ -5545,7 +5567,7 @@ intend a regexp match. @cindex regular expressions, dynamic, with embedded newlines @cindex newlines, in dynamic regexps -Some versions of @command{awk} do not allow the newline +Some older versions of @command{awk} do not allow the newline character to be used inside a bracket expression for a dynamic regexp: @example @@ -5554,7 +5576,7 @@ $ @kbd{awk '$0 ~ "[ \t\n]"'} @error{} ]... @error{} source line number 1 @error{} context is -@error{} >>> <<< +@error{} $0 ~ "[ >>> \t\n]" <<< @end example @cindex newlines, in regexp constants @@ -5877,11 +5899,6 @@ Within bracket expressions, POSIX character classes let you specify certain groups of characters in a locale-independent fashion. @item -@command{gawk}'s @code{IGNORECASE} variable lets you control the -case sensitivity of regexp matching. In other @command{awk} -versions, use @code{tolower()} or @code{toupper()}. - -@item Regular expressions match the leftmost longest text in the string being matched. This matters for cases where you need to know the extent of the match, such as for text substitution and when the record separator @@ -5891,6 +5908,11 @@ is a regexp. Matching expressions may use dynamic regexps, that is, string values treated as regular expressions. +@item +@command{gawk}'s @code{IGNORECASE} variable lets you control the +case sensitivity of regexp matching. In other @command{awk} +versions, use @code{tolower()} or @code{toupper()}. + @end itemize @c ENDOFRANGE regexp @@ -5958,7 +5980,7 @@ used with it do not have to be named on the @command{awk} command line @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. +called @code{FNR} which is reset to zero every time 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. @@ -6088,7 +6110,8 @@ Using an unusual character such as @samp{/} is more likely to produce correct behavior in the majority of cases, but there are no guarantees. The moral is: Know Your Data. -There is one unusual case, that occurs when @command{gawk} is +When using regular characters as the record separator, +there is one unusual case that occurs when @command{gawk} is being fully POSIX-compliant (@pxref{Options}). Then, the following (extreme) pipeline prints a surprising @samp{1}: @@ -6177,7 +6200,7 @@ $ @kbd{echo record 1 AAAA record 2 BBBB record 3 |} @noindent The square brackets delineate the contents of @code{RT}, letting you -see the leading and trailing whitespace. The final value of @code{RT} +see the leading and trailing whitespace. The final value of @code{RT} is a newline. @xref{Simple Sed}, for a more useful example of @code{RS} as a regexp and @code{RT}. @@ -6196,7 +6219,7 @@ metacharacters match the beginning and end of a @emph{string}, and not the beginning and end of a @emph{line}. As a result, something like @samp{RS = "^[[:upper:]]"} can only match at the beginning of a file. This is because @command{gawk} views the input file as one long string -that happens to contain newline characters in it. +that happens to contain newline characters. It is thus best to avoid anchor characters in the value of @code{RS}. @end quotation @@ -6206,7 +6229,7 @@ variable are @command{gawk} extensions; they are not available in compatibility mode (@pxref{Options}). In compatibility mode, only the first character of the value of -@code{RS} is used to determine the end of the record. +@code{RS} determines the end of the record. @sidebar @code{RS = "\0"} Is Not Portable @cindex portability, data files as single record @@ -6242,10 +6265,11 @@ about.} store strings internally as C-style strings. C strings use the It happens that recent versions of @command{mawk} can use the @value{NUL} character as a record separator. However, this is a special case: @command{mawk} does not allow embedded @value{NUL} characters in strings. +(This may change in a future version of @command{mawk}.) @cindex records, treating files as @cindex treating files, as single records -@xref{Readfile Function}, for an interesting, portable way to read +@xref{Readfile Function}, for an interesting way to read whole files. If you are using @command{gawk}, see @ref{Extension Sample Readfile}, for another option. @end sidebar @@ -6326,15 +6350,11 @@ $ @kbd{awk '$1 ~ /li/ @{ print $0 @}' mail-list} @noindent This example prints each record in the file @file{mail-list} whose first -field contains the string @samp{li}. The operator @samp{~} is called a -@dfn{matching operator} -(@pxref{Regexp Usage}); -it tests whether a string (here, the field @code{$1}) matches a given regular -expression. +field contains the string @samp{li}. -By contrast, the following example -looks for @samp{li} in @emph{the entire record} and prints the first -field and the last field for each matching input record: +By contrast, the following example looks for @samp{li} in @emph{the +entire record} and prints the first and last fields for each matching +input record: @example $ @kbd{awk '/li/ @{ print $1, $NF @}' mail-list} @@ -6457,8 +6477,8 @@ It is also possible to also assign contents to fields that are out of range. For example: @example -$ awk '@{ $6 = ($5 + $4 + $3 + $2) -> print $6 @}' inventory-shipped +$ @kbd{awk '@{ $6 = ($5 + $4 + $3 + $2)} +> @kbd{ print $6 @}' inventory-shipped} @print{} 168 @print{} 297 @print{} 301 @@ -6547,7 +6567,7 @@ Here is an example: @example $ echo a b c d e f | awk '@{ print "NF =", NF; -> NF = 3; print $0 @}' +> NF = 3; print $0 @}' @print{} NF = 6 @print{} a b c @end example @@ -6555,7 +6575,7 @@ $ echo a b c d e f | awk '@{ print "NF =", NF; @cindex portability, @code{NF} variable@comma{} decrementing @quotation CAUTION Some versions of @command{awk} don't -rebuild @code{$0} when @code{NF} is decremented. Caveat emptor. +rebuild @code{$0} when @code{NF} is decremented. @end quotation Finally, there are times when it is convenient to force @@ -6586,7 +6606,7 @@ record, exactly as it was read from the input. This includes any leading or trailing whitespace, and the exact whitespace (or other characters) that separate the fields. -It is a not-uncommon error to try to change the field separators +It is a common error to try to change the field separators in a record simply by setting @code{FS} and @code{OFS}, and then expecting a plain @samp{print} or @samp{print $0} to print the modified record. @@ -6789,9 +6809,10 @@ $ @kbd{echo ' a b c d' | awk '@{ print; $2 = $2; print @}'} The first @code{print} statement prints the record as it was read, with leading whitespace intact. The assignment to @code{$2} rebuilds @code{$0} by concatenating @code{$1} through @code{$NF} together, -separated by the value of @code{OFS}. Because the leading whitespace -was ignored when finding @code{$1}, it is not part of the new @code{$0}. -Finally, the last @code{print} statement prints the new @code{$0}. +separated by the value of @code{OFS} (which is a space by default). +Because the leading whitespace was ignored when finding @code{$1}, +it is not part of the new @code{$0}. Finally, the last @code{print} +statement prints the new @code{$0}. @cindex @code{FS}, containing @code{^} @cindex @code{^} (caret), in @code{FS} @@ -6813,7 +6834,7 @@ also works this way. For example: @example $ @kbd{echo 'xxAA xxBxx C' |} > @kbd{gawk -F '(^x+)|( +)' '@{ for (i = 1; i <= NF; i++)} -> @kbd{printf "-->%s<--\n", $i @}'} +> @kbd{ printf "-->%s<--\n", $i @}'} @print{} --><-- @print{} -->AA<-- @print{} -->xxBxx<-- @@ -6876,12 +6897,7 @@ awk -F, '@var{program}' @var{input-files} @noindent sets @code{FS} to the @samp{,} character. Notice that the option uses an uppercase @samp{F} instead of a lowercase @samp{f}. The latter -option (@option{-f}) specifies a file -containing an @command{awk} program. Case is significant in command-line -options: -the @option{-F} and @option{-f} options have nothing to do with each other. -You can use both options at the same time to set the @code{FS} variable -@emph{and} get an @command{awk} program from a file. +option (@option{-f}) specifies a file containing an @command{awk} program. The value used for the argument to @option{-F} is processed in exactly the same way as assignments to the built-in variable @code{FS}. @@ -6995,7 +7011,7 @@ to @code{FS} (the backslash is stripped). This creates a regexp meaning If instead you want fields to be separated by a literal period followed by any single character, use @samp{FS = "\\.."}. -The following table summarizes how fields are split, based on the value +The following list summarizes how fields are split, based on the value of @code{FS} (@samp{==} means ``is equal to''): @table @code @@ -7016,8 +7032,7 @@ Leading and trailing matches of @var{regexp} delimit empty fields. @item FS == "" Each individual character in the record becomes a separate field. -(This is a @command{gawk} extension; it is not specified by the -POSIX standard.) +(This is a common extension; it is not specified by the POSIX standard.) @end table @sidebar Changing @code{FS} Does Not Affect the Fields @@ -7469,7 +7484,7 @@ BEGIN @{ RS = "" ; FS = "\n" @} Running the program produces the following output: @example -$ awk -f addrs.awk addresses +$ @kbd{awk -f addrs.awk addresses} @print{} Name is: Jane Doe @print{} Address is: 123 Main Street @print{} City and State are: Anywhere, SE 12345-6789 @@ -7481,12 +7496,9 @@ $ awk -f addrs.awk addresses @dots{} @end example -@xref{Labels Program}, for a more realistic -program that deals with address lists. -The following -table -summarizes how records are split, based on the -value of +@xref{Labels Program}, for a more realistic program that deals with +address lists. The following list summarizes how records are split, +based on the value of @ifinfo @code{RS}. (@samp{==} means ``is equal to.'') @@ -7521,8 +7533,8 @@ POSIX standard.) @cindex @command{gawk}, @code{RT} variable in @cindex @code{RT} variable -In all cases, @command{gawk} sets @code{RT} to the input text that matched the -value specified by @code{RS}. +If not in compatibility mode (@pxref{Options}), @command{gawk} sets +@code{RT} to the input text that matched the value specified by @code{RS}. But if the input file ended without any text that matches @code{RS}, then @command{gawk} sets @code{RT} to the null string. @c ENDOFRANGE recm @@ -7620,9 +7632,7 @@ processing on the next record @emph{right now}. For example: while (j == 0) @{ # get more text if (getline <= 0) @{ - m = "unexpected EOF or error" - m = (m ": " ERRNO) - print m > "/dev/stderr" + print("unexpected EOF or error:", ERRNO) > "/dev/stderr" exit @} # build up the line using string concatenation @@ -7891,7 +7901,7 @@ bletch @end example @noindent -Notice that this program ran the command @command{who} and printed the previous result. +Notice that this program ran the command @command{who} and printed the result. (If you try this program yourself, you will of course get different results, depending upon who is logged in on your system.) @@ -7916,7 +7926,7 @@ Unfortunately, @command{gawk} has not been consistent in its treatment of a construct like @samp{@w{"echo "} "date" | getline}. Most versions, including the current version, treat it at as @samp{@w{("echo "} "date") | getline}. -(This how BWK @command{awk} behaves.) +(This is also how BWK @command{awk} behaves.) Some versions changed and treated it as @samp{@w{"echo "} ("date" | getline)}. (This is how @command{mawk} behaves.) @@ -7944,7 +7954,7 @@ BEGIN @{ @end example In this version of @code{getline}, none of the built-in variables are -changed and the record is not split into fields. +changed and the record is not split into fields. However, @code{RT} is set. @ifinfo @c Thanks to Paul Eggert for initial wording here @@ -8052,7 +8062,7 @@ causes @command{awk} to set the value of @code{FILENAME}. Normally, @code{FILENAME} does not have a value inside @code{BEGIN} rules, because you have not yet started to process the command-line @value{DF}s. @value{DARKCORNER} -(@xref{BEGIN/END}, +(See @ref{BEGIN/END}; also @pxref{Auto-set}.) @item @@ -8099,7 +8109,7 @@ end of file is encountered, before the element in @code{a} is assigned? @command{gawk} treats @code{getline} like a function call, and evaluates the expression @samp{a[++c]} before attempting to read from @file{f}. However, some versions of @command{awk} only evaluate the expression once they -know that there is a string value to be assigned. Caveat Emptor. +know that there is a string value to be assigned. @end itemize @node Getline Summary @@ -8115,15 +8125,15 @@ Note: for each variant, @command{gawk} sets the @code{RT} built-in variable. @float Table,table-getline-variants @caption{@code{getline} Variants and What They Set} @multitable @columnfractions .33 .38 .27 -@headitem Variant @tab Effect @tab Standard / Extension -@item @code{getline} @tab Sets @code{$0}, @code{NF}, @code{FNR}, @code{NR}, and @code{RT} @tab Standard -@item @code{getline} @var{var} @tab Sets @var{var}, @code{FNR}, @code{NR}, and @code{RT} @tab Standard -@item @code{getline <} @var{file} @tab Sets @code{$0}, @code{NF}, and @code{RT} @tab Standard -@item @code{getline @var{var} < @var{file}} @tab Sets @var{var} and @code{RT} @tab Standard -@item @var{command} @code{| getline} @tab Sets @code{$0}, @code{NF}, and @code{RT} @tab Standard -@item @var{command} @code{| getline} @var{var} @tab Sets @var{var} and @code{RT} @tab Standard -@item @var{command} @code{|& getline} @tab Sets @code{$0}, @code{NF}, and @code{RT} @tab Extension -@item @var{command} @code{|& getline} @var{var} @tab Sets @var{var} and @code{RT} @tab Extension +@headitem Variant @tab Effect @tab @command{awk} / @command{gawk} +@item @code{getline} @tab Sets @code{$0}, @code{NF}, @code{FNR}, @code{NR}, and @code{RT} @tab @command{awk} +@item @code{getline} @var{var} @tab Sets @var{var}, @code{FNR}, @code{NR}, and @code{RT} @tab @command{awk} +@item @code{getline <} @var{file} @tab Sets @code{$0}, @code{NF}, and @code{RT} @tab @command{awk} +@item @code{getline @var{var} < @var{file}} @tab Sets @var{var} and @code{RT} @tab @command{awk} +@item @var{command} @code{| getline} @tab Sets @code{$0}, @code{NF}, and @code{RT} @tab @command{awk} +@item @var{command} @code{| getline} @var{var} @tab Sets @var{var} and @code{RT} @tab @command{awk} +@item @var{command} @code{|& getline} @tab Sets @code{$0}, @code{NF}, and @code{RT} @tab @command{gawk} +@item @var{command} @code{|& getline} @var{var} @tab Sets @var{var} and @code{RT} @tab @command{gawk} @end multitable @end float @c ENDOFRANGE getl @@ -8140,7 +8150,7 @@ This @value{SECTION} describes a feature that is specific to @command{gawk}. You may specify a timeout in milliseconds for reading input from the keyboard, a pipe, or two-way communication, including TCP/IP sockets. This can be done on a per input, command or connection basis, by setting a special element -in the @code{PROCINFO} (@pxref{Auto-set}) array: +in the @code{PROCINFO} array (@pxref{Auto-set}): @example PROCINFO["input_name", "READ_TIMEOUT"] = @var{timeout in milliseconds} @@ -8172,7 +8182,7 @@ while ((getline < "/dev/stdin") > 0) @command{gawk} terminates the read operation if input does not arrive after waiting for the timeout period, returns failure -and sets the @code{ERRNO} variable to an appropriate string value. +and sets @code{ERRNO} to an appropriate string value. A negative or zero value for the timeout is the same as specifying no timeout at all. @@ -8279,6 +8289,10 @@ The possibilities are as follows: @end multitable @item +@code{FNR} indicates how many records have been read from the current input file; +@code{NR} indicates how many records have been read in total. + +@item @command{gawk} sets @code{RT} to the text matched by @code{RS}. @item @@ -8289,7 +8303,7 @@ fields there are. The default way to split fields is between whitespace characters. @item -Fields may be referenced using a variable, as in @samp{$NF}. Fields +Fields may be referenced using a variable, as in @code{$NF}. Fields may also be assigned values, which causes the value of @code{$0} to be recomputed when it is later referenced. Assigning to a field with a number greater than @code{NF} creates the field and rebuilds the record, using @@ -8299,16 +8313,17 @@ thing. Decrementing @code{NF} throws away fields and rebuilds the record. @item Field splitting is more complicated than record splitting. -@multitable @columnfractions .40 .40 .20 +@multitable @columnfractions .40 .45 .15 @headitem Field separator value @tab Fields are split @dots{} @tab @command{awk} / @command{gawk} @item @code{FS == " "} @tab On runs of whitespace @tab @command{awk} @item @code{FS == @var{any single character}} @tab On that character @tab @command{awk} @item @code{FS == @var{regexp}} @tab On text matching the regexp @tab @command{awk} @item @code{FS == ""} @tab Each individual character is a separate field @tab @command{gawk} @item @code{FIELDWIDTHS == @var{list of columns}} @tab Based on character position @tab @command{gawk} -@item @code{FPAT == @var{regexp}} @tab On text around text matching the regexp @tab @command{gawk} +@item @code{FPAT == @var{regexp}} @tab On the text surrounding text matching the regexp @tab @command{gawk} @end multitable +@item Using @samp{FS = "\n"} causes the entire record to be a single field (assuming that newlines separate records). @@ -8317,11 +8332,11 @@ Using @samp{FS = "\n"} causes the entire record to be a single field This can also be done using command-line variable assignment. @item -@code{PROCINFO["FS"]} can be used to see how fields are being split. +Use @code{PROCINFO["FS"]} to see how fields are being split. @item Use @code{getline} in its various forms to read additional records, -from the default input stream, from a file, or from a pipe or co-process. +from the default input stream, from a file, or from a pipe or coprocess. @item Use @code{PROCINFO[@var{file}, "READ_TIMEOUT"]} to cause reads to timeout @@ -8401,7 +8416,7 @@ and discusses the @code{close()} built-in function. @node Print @section The @code{print} Statement -The @code{print} statement is used for producing output with simple, standardized +Use the @code{print} statement to produce output with simple, standardized formatting. You specify only the strings or numbers to print, in a list separated by commas. They are output, separated by single spaces, followed by a newline. The statement looks like this: @@ -8425,7 +8440,7 @@ expression. Numeric values are converted to strings and then printed. @cindex text, printing The simple statement @samp{print} with no items is equivalent to @samp{print $0}: it prints the entire current record. To print a blank -line, use @samp{print ""}, where @code{""} is the empty string. +line, use @samp{print ""}. To print a fixed piece of text, use a string constant, such as @w{@code{"Don't Panic"}}, as one item. If you forget to use the double-quote characters, your text is taken as an @command{awk} @@ -8433,8 +8448,8 @@ expression, and you will probably get an error. Keep in mind that a space is printed between any two items. Note that the @code{print} statement is a statement and not an -expression---you can't use it the pattern part of a pattern-action -statement, for example. +expression---you can't use it in the pattern part of a +@var{pattern}-@var{action} statement, for example. @node Print Examples @section @code{print} Statement Examples @@ -8445,9 +8460,22 @@ newline, the newline is output along with the rest of the string. A single @code{print} statement can make any number of lines this way. @cindex newlines, printing -The following is an example of printing a string that contains embedded newlines +The following is an example of printing a string that contains embedded +@ifinfo +newlines +(the @samp{\n} is an escape sequence, used to represent the newline +character; @pxref{Escape Sequences}): +@end ifinfo +@ifhtml +newlines (the @samp{\n} is an escape sequence, used to represent the newline character; @pxref{Escape Sequences}): +@end ifhtml +@ifnotinfo +@ifnothtml +newlines: +@end ifnothtml +@end ifnotinfo @example $ @kbd{awk 'BEGIN @{ print "line one\nline two\nline three" @}'} @@ -8627,13 +8655,13 @@ more fully in @cindexawkfunc{sprintf} @cindex @code{OFMT} variable @cindex output, format specifier@comma{} @code{OFMT} -The built-in variable @code{OFMT} contains the default format specification +The built-in variable @code{OFMT} contains the format specification that @code{print} uses with @code{sprintf()} when it wants to convert a number to a string for printing. The default value of @code{OFMT} is @code{"%.6g"}. The way @code{print} prints numbers can be changed -by supplying different format specifications -as the value of @code{OFMT}, as shown in the following example: +by supplying a different format specification +for the value of @code{OFMT}, as shown in the following example: @example $ @kbd{awk 'BEGIN @{} @@ -8663,9 +8691,7 @@ With @code{printf} you can specify the width to use for each item, as well as various formatting choices for numbers (such as what output base to use, whether to print an exponent, whether to print a sign, and how many digits to print -after the decimal point). You do this by supplying a string, called -the @dfn{format string}, that controls how and where to print the other -arguments. +after the decimal point). @menu * Basic Printf:: Syntax of the @code{printf} statement. @@ -8685,10 +8711,10 @@ printf @var{format}, @var{item1}, @var{item2}, @dots{} @end example @noindent -The entire list of arguments may optionally be enclosed in parentheses. The -parentheses are necessary if any of the item expressions use the @samp{>} -relational operator; otherwise, it can be confused with an output redirection -(@pxref{Redirection}). +As print @code{print}, the entire list of arguments may optionally be +enclosed in parentheses. Here too, the parentheses are necessary if any +of the item expressions use the @samp{>} relational operator; otherwise, +it can be confused with an output redirection (@pxref{Redirection}). @cindex format specifiers The difference between @code{printf} and @code{print} is the @var{format} @@ -8711,10 +8737,10 @@ on @code{printf} statements. For example: @example $ @kbd{awk 'BEGIN @{} > @kbd{ORS = "\nOUCH!\n"; OFS = "+"} -> @kbd{msg = "Dont Panic!"} +> @kbd{msg = "Don\47t Panic!"} > @kbd{printf "%s\n", msg} > @kbd{@}'} -@print{} Dont Panic! +@print{} Don't Panic! @end example @noindent @@ -8736,7 +8762,7 @@ the field width. Here is a list of the format-control letters: @c @asis for docbook to come out right @table @asis @item @code{%c} -Print a number as an ASCII character; thus, @samp{printf "%c", +Print a number as a character; thus, @samp{printf "%c", 65} outputs the letter @samp{A}. The output for a string value is the first character of the string. @@ -8762,7 +8788,7 @@ a single byte (0--255). @item @code{%d}, @code{%i} Print a decimal integer. The two control letters are equivalent. -(The @samp{%i} specification is for compatibility with ISO C.) +(The @code{%i} specification is for compatibility with ISO C.) @item @code{%e}, @code{%E} Print a number in scientific (exponential) notation; @@ -8777,7 +8803,7 @@ prints @samp{1.950e+03}, with a total of four significant figures, three of which follow the decimal point. (The @samp{4.3} represents two modifiers, discussed in the next @value{SUBSECTION}.) -@samp{%E} uses @samp{E} instead of @samp{e} in the output. +@code{%E} uses @samp{E} instead of @samp{e} in the output. @item @code{%f} Print a number in floating-point notation. @@ -8803,16 +8829,16 @@ The special ``not a number'' value formats as @samp{-nan} or @samp{nan} (@pxref{Math Definitions}). @item @code{%F} -Like @samp{%f} but the infinity and ``not a number'' values are spelled +Like @code{%f} but the infinity and ``not a number'' values are spelled using uppercase letters. -The @samp{%F} format is a POSIX extension to ISO C; not all systems -support it. On those that don't, @command{gawk} uses @samp{%f} instead. +The @code{%F} format is a POSIX extension to ISO C; not all systems +support it. On those that don't, @command{gawk} uses @code{%f} instead. @item @code{%g}, @code{%G} Print a number in either scientific notation or in floating-point notation, whichever uses fewer characters; if the result is printed in -scientific notation, @samp{%G} uses @samp{E} instead of @samp{e}. +scientific notation, @code{%G} uses @samp{E} instead of @samp{e}. @item @code{%o} Print an unsigned octal integer @@ -8828,7 +8854,7 @@ are floating-point; it is provided primarily for compatibility with C.) @item @code{%x}, @code{%X} Print an unsigned hexadecimal integer; -@samp{%X} uses the letters @samp{A} through @samp{F} +@code{%X} uses the letters @samp{A} through @samp{F} instead of @samp{a} through @samp{f} (@pxref{Nondecimal-numbers}). @@ -8843,7 +8869,7 @@ argument and it ignores any modifiers. @quotation NOTE When using the integer format-control letters for values that are outside the range of the widest C integer type, @command{gawk} switches to -the @samp{%g} format specifier. If @option{--lint} is provided on the +the @code{%g} format specifier. If @option{--lint} is provided on the command line (@pxref{Options}), @command{gawk} warns about this. Other versions of @command{awk} may print invalid values or do something else entirely. @@ -8859,7 +8885,7 @@ values or do something else entirely. A format specification can also include @dfn{modifiers} that can control how much of the item's value is printed, as well as how much space it gets. The modifiers come between the @samp{%} and the format-control letter. -We will use the bullet symbol ``@bullet{}'' in the following examples to +We use the bullet symbol ``@bullet{}'' in the following examples to represent spaces in the output. Here are the possible modifiers, in the order in which they may appear: @@ -8890,7 +8916,7 @@ It is in fact a @command{gawk} extension, intended for use in translating messages at runtime. @xref{Printf Ordering}, which describes how and why to use positional specifiers. -For now, we will not use them. +For now, we ignore them. @item - The minus sign, used before the width modifier (see later on in @@ -8918,15 +8944,15 @@ to format is positive. The @samp{+} overrides the space modifier. @item # Use an ``alternate form'' for certain control letters. -For @samp{%o}, supply a leading zero. -For @samp{%x} and @samp{%X}, supply a leading @samp{0x} or @samp{0X} for +For @code{%o}, supply a leading zero. +For @code{%x} and @code{%X}, supply a leading @code{0x} or @samp{0X} for a nonzero result. -For @samp{%e}, @samp{%E}, @samp{%f}, and @samp{%F}, the result always +For @code{%e}, @code{%E}, @code{%f}, and @code{%F}, the result always contains a decimal point. -For @samp{%g} and @samp{%G}, trailing zeros are not removed from the result. +For @code{%g} and @code{%G}, trailing zeros are not removed from the result. @item 0 -A leading @samp{0} (zero) acts as a flag that indicates that output should be +A leading @samp{0} (zero) acts as a flag indicating that output should be padded with zeros instead of spaces. This applies only to the numeric output formats. This flag only has an effect when the field width is wider than the @@ -9112,7 +9138,7 @@ the @command{awk} program: @example awk 'BEGIN @{ print "Name Number" print "---- ------" @} - @{ printf "%-10s %s\n", $1, $2 @}' mail-list + @{ printf "%-10s %s\n", $1, $2 @}' mail-list @end example The above example mixes @code{print} and @code{printf} statements in @@ -9122,7 +9148,7 @@ same results: @example awk 'BEGIN @{ printf "%-10s %s\n", "Name", "Number" printf "%-10s %s\n", "----", "------" @} - @{ printf "%-10s %s\n", $1, $2 @}' mail-list + @{ printf "%-10s %s\n", $1, $2 @}' mail-list @end example @noindent @@ -9137,7 +9163,7 @@ emphasized by storing it in a variable, like this: awk 'BEGIN @{ format = "%-10s %s\n" printf format, "Name", "Number" printf format, "----", "------" @} - @{ printf format, $1, $2 @}' mail-list + @{ printf format, $1, $2 @}' mail-list @end example @c ENDOFRANGE printfs @@ -9158,7 +9184,7 @@ This is called @dfn{redirection}. @quotation NOTE When @option{--sandbox} is specified (@pxref{Options}), -redirecting output to files and pipes is disabled. +redirecting output to files, pipes and coprocesses is disabled. @end quotation A redirection appears after the @code{print} or @code{printf} statement. @@ -9255,17 +9281,11 @@ in an @command{awk} script run periodically for system maintenance: @example report = "mail bug-system" -print "Awk script failed:", $0 | report -m = ("at record number " FNR " of " FILENAME) -print m | report +print("Awk script failed:", $0) | report +print("at record number", FNR, "of", FILENAME) | report close(report) @end example -The message is built using string concatenation and saved in the variable -@code{m}. It's then sent down the pipeline to the @command{mail} program. -(The parentheses group the items to concatenate---see -@ref{Concatenation}.) - The @code{close()} function is called here because it's a good idea to close the pipe as soon as all the intended output has been sent to it. @xref{Close Files And Pipes}, @@ -9376,7 +9396,7 @@ It then sends the list to the shell for execution. @cindex @command{gawk}, file names in @command{gawk} provides a number of special @value{FN}s that it interprets -internally. These @value{FN}s provide access to standard file descriptors +internally. These @value{FN}s provide access to standard pre-opened files and TCP/IP networking. @menu @@ -9386,7 +9406,7 @@ and TCP/IP networking. @end menu @node Special FD -@subsection Special Files for Standard Descriptors +@subsection Special Files for Standard Pre-Opened Files @cindex standard input @cindex input, standard @cindex standard output @@ -9434,7 +9454,7 @@ that is connected to your keyboard and screen. It represents the ``terminal,''@footnote{The ``tty'' in @file{/dev/tty} stands for ``Teletype,'' a serial terminal.} which on modern systems is a keyboard and screen, not a serial console.) -This usually has the same effect but not always: although the +This generally has the same effect but not always: although the standard error stream is usually the screen, it can be redirected; when that happens, writing to the screen is not correct. In fact, if @command{awk} is run from a background job, it may not have a @@ -9443,9 +9463,12 @@ Then opening @file{/dev/tty} fails. @command{gawk} provides special @value{FN}s for accessing the three standard streams. @value{COMMONEXT} It also provides syntax for accessing -any other inherited open files. If the @value{FN} matches +any other inherited open files. +These open files are often referred to by the technical term +@dfn{file descriptor}. +If the @value{FN} matches one of these special names when @command{gawk} redirects input or output, -then it directly uses the stream that the @value{FN} stands for. +then it directly uses the descriptor that the @value{FN} stands for. These special @value{FN}s work for all operating systems that @command{gawk} has been ported to, not just those that are POSIX-compliant: @@ -9528,7 +9551,7 @@ Full discussion is delayed until @node Special Caveats @subsection Special @value{FFN} Caveats -Here is a list of things to bear in mind when using the +Here are some things to bear in mind when using the special @value{FN}s that @command{gawk} provides: @itemize @value{BULLET} @@ -9706,7 +9729,8 @@ to a string indicating the error. Note also that @samp{close(FILENAME)} has no ``magic'' effects on the implicit loop that reads through the files named on the command line. It is, more likely, a close of a file that was never opened with a -redirection, so @command{awk} silently does nothing. +redirection, so @command{awk} silently does nothing, except return +a negative value. @cindex @code{|} (vertical bar), @code{|&} operator (I/O), pipes@comma{} closing When using the @samp{|&} operator to communicate with a coprocess, @@ -9718,10 +9742,10 @@ the first argument is the name of the command or special file used to start the coprocess. The second argument should be a string, with either of the values @code{"to"} or @code{"from"}. Case does not matter. -As this is an advanced feature, a more complete discussion is +As this is an advanced feature, discussion is delayed until @ref{Two-way I/O}, -which discusses it in more detail and gives an example. +which describes it in more detail and gives an example. @sidebar Using @code{close()}'s Return Value @cindex dark corner, @code{close()} function @@ -9793,15 +9817,15 @@ that modify the behavior of the format control letters. @item Output from both @code{print} and @code{printf} may be redirected to -files, pipes, and co-processes. +files, pipes, and coprocesses. @item @command{gawk} provides special file names for access to standard input, output and error, and for network communications. @item -Use @code{close()} to close open file, pipe and co-process redirections. -For co-processes, it is possible to close only one direction of the +Use @code{close()} to close open file, pipe and coprocess redirections. +For coprocesses, it is possible to close only one direction of the communications. @end itemize @@ -11478,7 +11502,7 @@ so similar, this kind of error is very difficult to spot when scanning the source code. @cindex @command{gawk}, comparison operators and -The following table of expressions illustrates the kind of comparison +The following list of expressions illustrates the kind of comparison @command{gawk} performs, as well as what the result of the comparison is: @table @code @@ -11969,7 +11993,7 @@ expression because the first @samp{$} has higher precedence than the @samp{++}; to avoid the problem the expression can be rewritten as @samp{$($0++)--}. -This table presents @command{awk}'s operators, in order of highest +This list presents @command{awk}'s operators, in order of highest to lowest precedence: @c @asis for docbook to come out right @@ -12139,7 +12163,7 @@ character}, to find the record terminator. Locales can affect how dates and times are formatted (@pxref{Time Functions}). For example, a common way to abbreviate the date September 4, 2015 in the United States is ``9/4/15.'' In many countries in -Europe, however, it is abbreviated ``4.9.15.'' Thus, the @samp{%x} +Europe, however, it is abbreviated ``4.9.15.'' Thus, the @code{%x} specification in a @code{"US"} locale might produce @samp{9/4/15}, while in a @code{"EUROPE"} locale, it might produce @samp{4.9.15}. @@ -17665,7 +17689,7 @@ of its ISO week number is 2013, even though its year is 2012. The full year of the ISO week number, as a decimal number. @item %h -Equivalent to @samp{%b}. +Equivalent to @code{%b}. @item %H The hour (24-hour clock) as a decimal number (00--23). @@ -17734,7 +17758,7 @@ The locale's ``appropriate'' date representation. @item %X The locale's ``appropriate'' time representation. -(This is @samp{%T} in the @code{"C"} locale.) +(This is @code{%T} in the @code{"C"} locale.) @item %y The year modulo 100 as a decimal number (00--99). @@ -17755,7 +17779,7 @@ no time zone is determinable. @item %Ec %EC %Ex %EX %Ey %EY %Od %Oe %OH @itemx %OI %Om %OM %OS %Ou %OU %OV %Ow %OW %Oy ``Alternate representations'' for the specifications -that use only the second letter (@samp{%c}, @samp{%C}, +that use only the second letter (@code{%c}, @code{%C}, and so on).@footnote{If you don't understand any of this, don't worry about it; these facilities are meant to make it easier to ``internationalize'' programs. @@ -18018,7 +18042,7 @@ For example, if you have a bit string @samp{10111001} and you shift it right by three bits, you end up with @samp{00010111}.@footnote{This example shows that 0's come in on the left side. For @command{gawk}, this is always true, but in some languages, it's possible to have the left side -fill with 1's. Caveat emptor.} +fill with 1's.} @c Purposely decided to use 0's and 1's here. 2/2001. If you start over again with @samp{10111001} and shift it left by three bits, you end up @@ -19094,7 +19118,7 @@ saving it in @code{start}. The last part of the code loops through each function name (from @code{$2} up to the marker, @samp{data:}), calling the function named by the field. The indirect function call itself occurs as a parameter in the call to @code{printf}. -(The @code{printf} format string uses @samp{%s} as the format specifier so that we +(The @code{printf} format string uses @code{%s} as the format specifier so that we can use functions that return strings, as well as numbers. Note that the result from the indirect call is concatenated with the empty string, in order to force it to be a string value.) @@ -24974,8 +24998,8 @@ the path, and an attempt is made to open the generated @value{FN}. The only way to test if a file can be read in @command{awk} is to go ahead and try to read it with @code{getline}; this is what @code{pathto()} does.@footnote{On some very old versions of @command{awk}, the test -@samp{getline junk < t} can loop forever if the file exists but is empty. -Caveat emptor.} If the file can be read, it is closed and the @value{FN} +@samp{getline junk < t} can loop forever if the file exists but is empty.} +If the file can be read, it is closed and the @value{FN} is returned: @ignore @@ -26155,7 +26179,6 @@ come into play; comparisons are based on character values only.@footnote{This is true because locale-based comparison occurs only when in POSIX compatibility mode, and since @code{asort()} and @code{asorti()} are @command{gawk} extensions, they are not available in that case.} -Caveat Emptor. @node Two-way I/O @section Two-Way Communications with Another Process @@ -26806,9 +26829,9 @@ those functions sort arrays. Or you may provide one of the predefined control strings that work for @code{PROCINFO["sorted_in"]}. @item -You can use the @samp{|&} operator to create a two-way pipe to a co-process. -You read from the co-process with @code{getline} and write to it with @code{print} -or @code{printf}. Use @code{close()} to close off the co-process completely, or +You can use the @samp{|&} operator to create a two-way pipe to a coprocess. +You read from the coprocess with @code{getline} and write to it with @code{print} +or @code{printf}. Use @code{close()} to close off the coprocess completely, or optionally, close off one side of the two-way communications. @item @@ -34209,7 +34232,7 @@ for case translation (@pxref{String Functions}). @item -A cleaner specification for the @samp{%c} format-control letter in the +A cleaner specification for the @code{%c} format-control letter in the @code{printf} function (@pxref{Control Letters}). @@ -36608,7 +36631,7 @@ need to use the @code{BINMODE} variable. This can cause problems with other Unix-like components that have been ported to MS-Windows that expect @command{gawk} to do automatic -translation of @code{"\r\n"}, since it won't. Caveat Emptor! +translation of @code{"\r\n"}, since it won't. @node VMS Installation @appendixsubsec How to Compile and Install @command{gawk} on Vax/VMS and OpenVMS @@ -40614,6 +40637,7 @@ Consistency issues: Use --foo, not -Wfoo when describing long options Use "Bell Laboratories", but not "Bell Labs". Use "behavior" instead of "behaviour". + Use "coprocess" instead of "co-process". Use "zeros" instead of "zeroes". Use "nonzero" not "non-zero". Use "runtime" not "run time" or "run-time". |