aboutsummaryrefslogtreecommitdiffstats
path: root/doc/gawk.info
diff options
context:
space:
mode:
Diffstat (limited to 'doc/gawk.info')
-rw-r--r--doc/gawk.info5621
1 files changed, 2957 insertions, 2664 deletions
diff --git a/doc/gawk.info b/doc/gawk.info
index 05434558..caa557e8 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
@@ -170,10 +170,10 @@ entitled "GNU Free Documentation License".
* Escape Sequences:: How to write nonprinting characters.
* Regexp Operators:: Regular Expression Operators.
* Bracket Expressions:: What can go between `[...]'.
-* GNU Regexp Operators:: Operators specific to GNU software.
-* Case-sensitivity:: How to do case-insensitive matching.
* Leftmost Longest:: How much text matches.
* Computed Regexps:: Using Dynamic Regexps.
+* GNU Regexp Operators:: Operators specific to GNU software.
+* Case-sensitivity:: How to do case-insensitive matching.
* Regexp Summary:: Regular expressions summary.
* Records:: Controlling how data is split into
records.
@@ -189,8 +189,8 @@ entitled "GNU Free Documentation License".
* Regexp Field Splitting:: Using regexps as the field separator.
* Single Character Fields:: Making each character a separate
field.
-* Command Line Field Separator:: Setting `FS' from the
- command line.
+* Command Line Field Separator:: Setting `FS' from the command
+ line.
* Full Line Fields:: Making the full line be a single
field.
* Field Splitting Summary:: Some final points and a summary table.
@@ -234,17 +234,19 @@ entitled "GNU Free Documentation License".
* Printf Examples:: Several examples.
* Redirection:: How to redirect output to multiple
files and pipes.
+* Special FD:: Special files for I/O.
* Special Files:: File name interpretation in
`gawk'. `gawk' allows
access to inherited file descriptors.
-* Special FD:: Special files for I/O.
+* Other Inherited Files:: Accessing other open files with
+ `gawk'.
* Special Network:: Special files for network
communications.
* Special Caveats:: Things to watch out for.
* Close Files And Pipes:: Closing Input and Output Files and
Pipes.
* Output Summary:: Output summary.
-* Output exercises:: Exercises.
+* Output Exercises:: Exercises.
* Values:: Constants, Variables, and Regular
Expressions.
* Constants:: String, numeric and regexp constants.
@@ -330,7 +332,7 @@ entitled "GNU Free Documentation License".
record.
* Nextfile Statement:: Stop processing the current file.
* Exit Statement:: Stop execution of `awk'.
-* Built-in Variables:: Summarizes the built-in variables.
+* Built-in Variables:: Summarizes the predefined variables.
* User-modified:: Built-in variables that you change to
control `awk'.
* Auto-set:: Built-in variables where `awk'
@@ -350,12 +352,12 @@ entitled "GNU Free Documentation License".
elements.
* Controlling Scanning:: Controlling the order in which arrays
are scanned.
-* Delete:: The `delete' statement removes an
- element from an array.
* Numeric Array Subscripts:: How to use numbers as subscripts in
`awk'.
* Uninitialized Subscripts:: Using Uninitialized variables as
subscripts.
+* Delete:: The `delete' statement removes an
+ element from an array.
* Multidimensional:: Emulating multidimensional arrays in
`awk'.
* Multiscanning:: Scanning multidimensional arrays.
@@ -414,6 +416,8 @@ entitled "GNU Free Documentation License".
* Getlocaltime Function:: A function to get formatted times.
* Readfile Function:: A function to read an entire file at
once.
+* Shell Quoting:: A function to quote strings for the
+ shell.
* Data File Management:: Functions for managing command-line
data files.
* Filetrans Function:: A function for handling data file
@@ -431,7 +435,7 @@ entitled "GNU Free Documentation License".
information.
* Walking Arrays:: A function to walk arrays of arrays.
* Library Functions Summary:: Summary of library functions.
-* Library exercises:: Exercises.
+* Library Exercises:: Exercises.
* Running Examples:: How to run these examples.
* Clones:: Clones of common utilities.
* Cut Program:: The `cut' utility.
@@ -528,7 +532,6 @@ entitled "GNU Free Documentation License".
* Extension API Description:: A full description of the API.
* Extension API Functions Introduction:: Introduction to the API functions.
* General Data Types:: The data types.
-* Requesting Values:: How to get a value.
* Memory Allocation Functions:: Functions for allocating memory.
* Constructor Functions:: Functions for creating values.
* Registration Functions:: Functions to register things with
@@ -541,6 +544,7 @@ entitled "GNU Free Documentation License".
* Two-way processors:: Registering a two-way processor.
* Printing Messages:: Functions for printing messages.
* Updating `ERRNO':: Functions for updating `ERRNO'.
+* Requesting Values:: How to get a value.
* Accessing Parameters:: Functions for accessing parameters.
* Symbol Table Access:: Functions for accessing global
variables.
@@ -579,9 +583,9 @@ entitled "GNU Free Documentation License".
processor.
* Extension Sample Read write array:: Serializing an array to a file.
* Extension Sample Readfile:: Reading an entire file into a string.
-* Extension Sample API Tests:: Tests for the API.
* Extension Sample Time:: An interface to `gettimeofday()'
and `sleep()'.
+* Extension Sample API Tests:: Tests for the API.
* gawkextlib:: The `gawkextlib' project.
* Extension summary:: Extension summary.
* Extension Exercises:: Exercises.
@@ -693,7 +697,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
@@ -775,14 +779,14 @@ rest of the file alone. Such jobs are often easy with `awk'. The
makes it easy to handle simple data-reformatting jobs.
The GNU implementation of `awk' is called `gawk'; if you invoke it
-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.
+with the proper options or environment variables 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'. So most of
+the time, we don't distinguish between `gawk' and other `awk'
+implementations.
- Using `awk' allows you to:
+ Using `awk' you can:
* Manage small, personal databases
@@ -803,9 +807,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 +822,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 +843,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
@@ -872,16 +878,16 @@ V Release 3.1 (1987). The version in System V Release 4 (1989) added
some new features and cleaned up the behavior in some of the "dark
corners" of the language. The specification for `awk' in the POSIX
Command Language and Utilities standard further clarified the language.
-Both the `gawk' designers and the original Bell Laboratories `awk'
-designers provided feedback for the POSIX specification.
+Both the `gawk' designers and the original `awk' designers at Bell
+Laboratories provided feedback for the POSIX specification.
- Paul Rubin wrote the GNU implementation, `gawk', in 1986. Jay
-Fenlason completed it, with advice from Richard Stallman. John Woods
-contributed parts of the code as well. In 1988 and 1989, David
-Trueman, with help from me, thoroughly reworked `gawk' for compatibility
-with the newer `awk'. Circa 1994, I became the primary maintainer.
-Current development focuses on bug fixes, performance improvements,
-standards compliance and, occasionally, new features.
+ Paul Rubin wrote `gawk' in 1986. Jay Fenlason completed it, with
+advice from Richard Stallman. John Woods contributed parts of the code
+as well. In 1988 and 1989, David Trueman, with help from me,
+thoroughly reworked `gawk' for compatibility with the newer `awk'.
+Circa 1994, I became the primary maintainer. Current development
+focuses on bug fixes, performance improvements, standards compliance
+and, occasionally, new features.
In May of 1997, Ju"rgen Kahrs felt the need for network access from
`awk', and with a little help from me, set about adding features to do
@@ -894,8 +900,8 @@ the `gawk' distribution). His code finally became part of the main
`awk'-level debugger. This version became available as `gawk' version
4.0, in 2011.
- *Note Contributors::, for a complete list of those who made
-important contributions to `gawk'.
+ *Note Contributors::, for a full list of those who made important
+contributions to `gawk'.

File: gawk.info, Node: Names, Next: This Manual, Prev: History, Up: Preface
@@ -905,23 +911,19 @@ A Rose by Any Other Name
The `awk' language has evolved over the years. Full details are
provided in *note Language History::. The language described in this
-Info file is often referred to as "new `awk'" (`nawk').
+Info file is often referred to as "new `awk'". By analogy, the
+original version of `awk' is referred to as "old `awk'."
- For some time after new `awk' was introduced, there were systems
-with multiple versions of `awk'. Some systems had an `awk' utility
-that implemented the original version of the `awk' language and a
-`nawk' utility for the new version. Others had an `oawk' version for
-the "old `awk'" language and plain `awk' for the new one. Still others
-only had one version, which is usually the new one.
+ Today, on most systems, when you run the `awk' utility, you get some
+version of new `awk'.(1) If your system's standard `awk' is the old
+one, you will see something like this if you try the test program:
- Today, only Solaris systems still use an old `awk' for the default
-`awk' utility. (A more modern `awk' lives in `/usr/xpg6/bin' on these
-systems.) All other modern systems use some version of new `awk'.(1)
+ $ awk 1 /dev/null
+ error--> awk: syntax error near line 1
+ error--> awk: bailing out near line 1
- It is likely that you already have some version of new `awk' on your
-system, which is what you should use when running your programs. (Of
-course, if you're reading this Info file, chances are good that you
-have `gawk'!)
+In this case, you should find a version of new `awk', or just install
+`gawk'!
Throughout this Info file, whenever we refer to a language feature
that should be available in any complete implementation of POSIX `awk',
@@ -930,7 +932,9 @@ specific to the GNU implementation, we use the term `gawk'.
---------- Footnotes ----------
- (1) Many of these systems use `gawk' for their `awk' implementation!
+ (1) Only Solaris systems still use an old `awk' for the default
+`awk' utility. A more modern `awk' lives in `/usr/xpg6/bin' on these
+systems.

File: gawk.info, Node: This Manual, Next: Conventions, Prev: Names, Up: Preface
@@ -950,8 +954,8 @@ programming language.
in the POSIX standard. It does so in the context of the `gawk'
implementation. While doing so, it also attempts to describe important
differences between `gawk' and other `awk' implementations.(1) Finally,
-any `gawk' features that are not in the POSIX standard for `awk' are
-noted.
+it notes any `gawk' features that are not in the POSIX standard for
+`awk'.
There are sidebars scattered throughout the Info file. They add a
more complete explanation of points that are relevant, but not likely
@@ -960,7 +964,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'
@@ -996,7 +1000,7 @@ building blocks for getting most things done in a program.
*note Patterns and Actions::, describes how to write patterns for
matching records, actions for doing something when a record is matched,
-and the built-in variables `awk' and `gawk' use.
+and the predefined variables `awk' and `gawk' use.
*note Arrays::, covers `awk''s one-and-only data structure:
associative arrays. Deleting array elements and whole arrays is also
@@ -1004,7 +1008,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
@@ -1021,18 +1026,18 @@ problems.
Part III focuses on features specific to `gawk'. It contains the
following chapters:
- *note Advanced Features::, describes a number of `gawk'-specific
-advanced features. Of particular note are the abilities to have
-two-way communications with another process, perform TCP/IP networking,
-and profile your `awk' programs.
+ *note Advanced Features::, describes a number of advanced features.
+Of particular note are the abilities to control the order of array
+traversal, have two-way communications with another process, perform
+TCP/IP networking, and profile your `awk' programs.
- *note Internationalization::, describes special features in `gawk'
-for translating program messages into different languages at runtime.
+ *note Internationalization::, describes special features for
+translating program messages into different languages at runtime.
- *note Debugger::, describes the `awk' debugger.
+ *note Debugger::, describes the `gawk' debugger.
*note Arbitrary Precision Arithmetic::, describes advanced
-arithmetic facilities provided by `gawk'.
+arithmetic facilities.
*note Dynamic Extensions::, describes how to add new variables and
functions to `gawk' by writing extensions in C or C++.
@@ -1119,8 +1124,8 @@ at all. Descriptions of such features (often called "dark corners")
are noted in this Info file with "(d.c.)". They also appear in the
index under the heading "dark corner."
- As noted by the opening quote, though, any coverage of dark corners
-is, by definition, incomplete.
+ But, as noted by the opening quote, any coverage of dark corners is
+by definition incomplete.
Extensions to the standard `awk' language that are supported by more
than one `awk' implementation are marked "(c.e.)," and listed in the
@@ -1160,7 +1165,7 @@ system for Intel, Power Architecture, Sun SPARC, IBM S/390, and other
systems.(2) Many GNU/Linux distributions are available for download
from the Internet.
- The Info file itself has gone through a number of previous editions.
+ The Info file itself has gone through multiple previous editions.
Paul Rubin wrote the very first draft of `The GAWK Manual'; it was
around 40 pages in size. Diane Close and Richard Stallman improved it,
yielding a version that was around 90 pages long and barely described
@@ -1173,17 +1178,16 @@ published the first two editions under the title `The GNU Awk User's
Guide'.
This edition maintains the basic structure of the previous editions.
-For FSF edition 4.0, the content has been thoroughly reviewed and
-updated. All references to `gawk' versions prior to 4.0 have been
-removed. Of significant note for this edition was *note Debugger::.
+For FSF edition 4.0, the content was thoroughly reviewed and updated.
+All references to `gawk' versions prior to 4.0 were removed. Of
+significant note for that edition was *note Debugger::.
For FSF edition 4.1, the content has been reorganized into parts,
and the major new additions are *note Arbitrary Precision Arithmetic::,
and *note Dynamic Extensions::.
- This Info file will undoubtedly continue to evolve. An electronic
-version comes with the `gawk' distribution from the FSF. If you find
-an error in this Info file, please report it! *Note Bugs::, for
+ This Info file will undoubtedly continue to evolve. If you find an
+error in this Info file, please report it! *Note Bugs::, for
information on submitting problem reports electronically.
---------- Footnotes ----------
@@ -1288,12 +1292,14 @@ Michal Jaegermann, Ju"rgen Kahrs, Stepan Kasal, John Malmberg, Dave
Pitts, Chet Ramey, Pat Rankin, Andrew Schorr, Corinna Vinschen, and Eli
Zaretskii (in alphabetical order) make up the current `gawk' "crack
portability team." Without their hard work and help, `gawk' would not
-be nearly the fine program it is today. It has been and continues to
-be a pleasure working with this team of fine people.
+be nearly the robust, portable program it is today. It has been and
+continues to be a pleasure working with this team of fine people.
Notable code and documentation contributions were made by a number
of people. *Note Contributors::, for the full list.
+ Thanks to Michael Brennan for the Foreword.
+
Thanks to Patrice Dumas for the new `makeinfo' program. Thanks to
Karl Berry who continues to work to keep the Texinfo markup language
sane.
@@ -1457,21 +1463,23 @@ end-of-file character may be different. For example, on OS/2, it is
As an example, the following program prints a friendly piece of
advice (from Douglas Adams's `The Hitchhiker's Guide to the Galaxy'),
to keep you from worrying about the complexities of computer
-programming (`BEGIN' is a feature we haven't discussed yet):
+programming:
- $ awk "BEGIN { print \"Don't Panic!\" }"
+ $ awk 'BEGIN { print "Don\47t Panic!" }'
-| Don't Panic!
- This program does not read any input. The `\' before each of the
-inner double quotes is necessary because of the shell's quoting
-rules--in particular because it mixes both single quotes and double
-quotes.(1)
+ `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 (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
@@ -1488,21 +1496,15 @@ works is explained shortly).
-| What, me worry?
Ctrl-d
- ---------- Footnotes ----------
-
- (1) Although we generally recommend the use of single quotes around
-the program text, double quotes are needed here in order to put the
-single quote into the message.
-

File: gawk.info, Node: Long, Next: Executable Scripts, Prev: Read Terminal, Up: Running gawk
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 ...
@@ -1518,14 +1520,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
@@ -1548,8 +1552,8 @@ like this:
BEGIN { print "Don't Panic!" }
After making this file executable (with the `chmod' utility), simply
-type `advice' at the shell and the system arranges to run `awk'(2) as
-if you had typed `awk -f advice':
+type `advice' at the shell and the system arranges to run `awk' as if
+you had typed `awk -f advice':
$ chmod +x advice
$ advice
@@ -1563,7 +1567,24 @@ at the shell.)
program that users can invoke without their having to know that the
program is written in `awk'.
- Portability Issues with `#!'
+ Understanding `#!'
+
+ `awk' is an "interpreted" language. This means that the `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 processor.) The `awk'
+utility is thus termed an "interpreter". Many modern languages are
+interperted.
+
+ The line beginning with `#!' lists the full file name of an
+interpreter to run and a single optional initial command-line argument
+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'.)
Some systems limit the length of the interpreter name to 32
characters. Often, this can be dealt with by using a symbolic link.
@@ -1585,15 +1606,6 @@ the name of your script (`advice'). (d.c.) Don't rely on the value of
(1) The `#!' mechanism works on GNU/Linux systems, BSD-based systems
and commercial Unix systems.
- (2) The line beginning with `#!' lists the full file name of an
-interpreter to run and a single optional initial command-line argument
-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.
-

File: gawk.info, Node: Comments, Next: Quoting, Prev: Executable Scripts, Up: Running gawk
@@ -1712,8 +1724,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!
@@ -1731,10 +1746,10 @@ the quoting rules.
awk -F"" 'PROGRAM' FILES # wrong!
- In the second case, `awk' will attempt to use the text of the
- program as the value of `FS', and the first file name as the text
- of the program! This results in syntax errors at best, and
- confusing behavior at worst.
+ In the second case, `awk' attempts to use the text of the program
+ as the value of `FS', and the first file name as the text of the
+ program! This results in syntax errors at best, and confusing
+ behavior at worst.
Mixing single and double quotes is difficult. You have to resort to
shell quoting tricks, like this:
@@ -1779,6 +1794,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.
@@ -1814,12 +1832,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
@@ -1838,7 +1856,8 @@ shipments during the year. Each record contains the month, the number
of green crates shipped, the number of red boxes shipped, the number of
orange bags shipped, and the number of blue packages shipped,
respectively. There are 16 entries, covering the 12 months of last year
-and the first four months of the current year.
+and the first four months of the current year. An empty line separates
+the data for the two years.
Jan 13 25 15 115
Feb 15 32 24 226
@@ -1918,11 +1937,6 @@ often more than one way to do things in `awk'. At some point, you may
want to look back at these examples and see if you can come up with
different ways to do the same things shown here:
- * Print the length of the longest input line:
-
- awk '{ if (length($0) > max) max = length($0) }
- END { print max }' data
-
* Print every line that is longer than 80 characters:
awk 'length($0) > 80' data
@@ -1930,15 +1944,23 @@ different ways to do the same things shown here:
The sole rule has a relational expression as its pattern and it
has no action--so it uses the default action, printing the record.
+ * Print the length of the longest input line:
+
+ awk '{ if (length($0) > max) max = length($0) }
+ END { print max }' data
+
+ The code associated with `END' executes after all input has been
+ read; it's the other side of the coin to `BEGIN'.
+
* 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 first example in this list:
- The input is processed by the `expand' utility to change TABs into
- spaces, so the widths compared are actually the right-margin
- columns, as opposed to the number of input characters on each line.
+ This example differs slightly from the previous one: The input is
+ processed by the `expand' utility to change TABs into spaces, so
+ the widths compared are actually the right-margin columns, as
+ opposed to the number of input characters on each line.
* Print every line that has at least one field:
@@ -1956,7 +1978,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:
@@ -1985,13 +2007,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:
@@ -2035,8 +2057,8 @@ summarize, select, and rearrange the output of another utility. It uses
features that haven't been covered yet, so don't worry if you don't
understand all the details:
- LC_ALL=C ls -l | awk '$6 == "Nov" { sum += $5 }
- END { print sum }'
+ ls -l | awk '$6 == "Nov" { sum += $5 }
+ END { print sum }'
This command prints the total number of bytes in all the files in the
current directory that were last modified in November (of any year).
@@ -2055,11 +2077,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
@@ -2081,11 +2103,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
@@ -2216,7 +2233,7 @@ determining the type of a variable, and array sorting.
As we develop our presentation of the `awk' language, we introduce
most of the variables and many of the functions. They are described
-systematically in *note Built-in Variables::, and *note Built-in::.
+systematically in *note Built-in Variables::, and in *note Built-in::.

File: gawk.info, Node: When, Next: Intro Summary, Prev: Other Features, Up: Getting Started
@@ -2243,9 +2260,7 @@ edit-compile-test-debug cycle of software development.
retargetable assembler for eight-bit microprocessors (*note Glossary::,
for more information), and a microcode assembler for a special-purpose
Prolog computer. While the original `awk''s capabilities were strained
-by tasks of such complexity, modern versions are more capable. Even
-BWK `awk' has fewer predefined limits, and those that it has are much
-larger than they used to be.
+by tasks of such complexity, modern versions are more capable.
If you find yourself writing `awk' scripts of more than, say, a few
hundred lines, you might consider using a different programming
@@ -2266,6 +2281,9 @@ File: gawk.info, Node: Intro Summary, Prev: When, Up: Getting Started
* Programs in `awk' consist of PATTERN-ACTION pairs.
+ * An ACTION without a PATTERN always runs. The default ACTION for a
+ pattern without one is `{ print $0 }'.
+
* Use either `awk 'PROGRAM' FILES' or `awk -f PROGRAM-FILE FILES' to
run `awk'.
@@ -2381,7 +2399,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
@@ -2432,9 +2450,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
@@ -2497,7 +2515,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,
@@ -2518,8 +2536,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]
@@ -2555,6 +2573,8 @@ The following list describes options mandated by the POSIX standard:
CAUTION: This option can severely break old programs. Use
with care.
+ This option may disappear in a future version of `gawk'.
+
`-N'
`--use-lc-numeric'
Force the use of the locale's decimal point character when parsing
@@ -2654,8 +2674,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'.
@@ -2712,14 +2733,21 @@ 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
+in *note ARGC and ARGV::.
The distinction between file name arguments and variable-assignment
arguments is made when `awk' is about to open the next input file. At
@@ -2824,8 +2852,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
@@ -2833,21 +2861,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
@@ -2894,15 +2921,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
@@ -2912,6 +2930,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:
@@ -2923,7 +2950,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
@@ -2937,11 +2964,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
@@ -2956,12 +2983,12 @@ change. The variables are:
evaluation stack, when needed.
`INT_CHAIN_MAX'
- The average number of items `gawk' will maintain on a hash chain
- for managing arrays indexed by integers.
+ The intended maximum number of items `gawk' will maintain on a
+ hash chain for managing arrays indexed by integers.
`STR_CHAIN_MAX'
- The average number of items `gawk' will maintain on a hash chain
- for managing arrays indexed by strings.
+ The intended maximum number of items `gawk' will maintain on a
+ hash chain for managing arrays indexed by strings.
`TIDYMEM'
If this variable exists, `gawk' uses the `mtrace()' library calls
@@ -3020,8 +3047,8 @@ and here is `test2':
Running `gawk' with `test2' produces the following result:
$ gawk -f test2
- -| This is file test1.
- -| This is file test2.
+ -| This is script test1.
+ -| This is script test2.
`gawk' runs the `test2' script which includes `test1' using the
`@include' keyword. So, to include external `awk' source files you just
@@ -3043,9 +3070,9 @@ namely `test3':
Running `gawk' with the `test3' script produces the following results:
$ gawk -f test3
- -| This is file test1.
- -| This is file test2.
- -| This is file test3.
+ -| This is script test1.
+ -| This is script test2.
+ -| This is script test3.
The file name can, of course, be a pathname. For example:
@@ -3115,7 +3142,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
@@ -3166,7 +3194,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
@@ -3200,7 +3229,7 @@ that matches every input record whose text belongs to that set. The
simplest regular expression is a sequence of letters, numbers, or both.
Such a regexp matches any string that contains that sequence. Thus,
the regexp `foo' matches any string containing `foo'. Therefore, the
-pattern `/foo/' matches any input record containing the three
+pattern `/foo/' matches any input record containing the three adjacent
characters `foo' _anywhere_ in the record. Other kinds of regexps let
you specify more complicated classes of strings.
@@ -3210,10 +3239,10 @@ you specify more complicated classes of strings.
* Escape Sequences:: How to write nonprinting characters.
* Regexp Operators:: Regular Expression Operators.
* Bracket Expressions:: What can go between `[...]'.
-* GNU Regexp Operators:: Operators specific to GNU software.
-* Case-sensitivity:: How to do case-insensitive matching.
* Leftmost Longest:: How much text matches.
* Computed Regexps:: Using Dynamic Regexps.
+* GNU Regexp Operators:: Operators specific to GNU software.
+* Case-sensitivity:: How to do case-insensitive matching.
* Regexp Summary:: Regular expressions summary.

@@ -3304,9 +3333,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, `\'.
@@ -3355,17 +3384,19 @@ apply to both string constants and regexp constants:
`\/'
A literal slash (necessary for regexp constants only). This
sequence is used when you want to write a regexp constant that
- contains a slash. Because the regexp is delimited by slashes, you
- need to escape the slash that is part of the pattern, in order to
+ contains a slash (such as `/.*:\/home\/[[:alnum:]]+:.*/'; the
+ `[[:alnum:]]' notation is discussed shortly, in *note Bracket
+ Expressions::). Because the regexp is delimited by slashes, you
+ need to escape any slash that is part of the pattern, in order to
tell `awk' to keep processing the rest of the regexp.
`\"'
A literal double quote (necessary for string constants only).
This sequence is used when you want to write a string constant
- that contains a double quote. Because the string is delimited by
- double quotes, you need to escape the quote that is part of the
- string, in order to tell `awk' to keep processing the rest of the
- string.
+ that contains a double quote (such as `"He said \"hi!\" to her."').
+ Because the string is delimited by double quotes, you need to
+ escape any quote that is part of the string, in order to tell
+ `awk' to keep processing the rest of the string.
In `gawk', a number of additional two-character sequences that begin
with a backslash have special meaning in regexps. *Note GNU Regexp
@@ -3378,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.
@@ -3440,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
@@ -3497,9 +3528,10 @@ sequences and that are not listed in the table stand for themselves:
`|'
This is the "alternation operator" and it is used to specify
alternatives. The `|' has the lowest precedence of all the regular
- expression operators. For example, `^P|[[:digit:]]' matches any
- string that matches either `^P' or `[[:digit:]]'. This means it
- matches any string that starts with `P' or contains a digit.
+ expression operators. For example, `^P|[aeiouy]' matches any
+ string that matches either `^P' or `[aeiouy]'. This means it
+ matches any string that starts with `P' or contains (anywhere
+ within it) a lowercase English vowel.
The alternation applies to the largest possible regexps on either
side.
@@ -3519,22 +3551,20 @@ sequences and that are not listed in the table stand for themselves:
matches of one `p' followed by any number of `h's. This also
matches just `p' if no `h's are present.
- The `*' repeats the _smallest_ possible preceding expression.
- (Use parentheses if you want to repeat a larger expression.) It
- finds as many repetitions as possible. For example, `awk
- '/\(c[ad][ad]*r x\)/ { print }' sample' prints every record in
- `sample' containing a string of the form `(car x)', `(cdr x)',
- `(cadr x)', and so on. Notice the escaping of the parentheses by
- preceding them with backslashes.
+ There are two subtle points to understand about how `*' works.
+ First, the `*' applies only to the single preceding regular
+ expression component (e.g., in `ph*', it applies just to the `h').
+ To cause `*' to apply to a larger sub-expression, use parentheses:
+ `(ph)*' matches `ph', `phph', `phphph' and so on.
+
+ Second, `*' finds as many repetitions as possible. If the text to
+ be matched is `phhhhhhhhhhhhhhooey', `ph*' matches all of the `h's.
`+'
This symbol is similar to `*', except that the preceding
expression must be matched at least once. This means that `wh+y'
would match `why' and `whhy', but not `wy', whereas `wh*y' would
- match all three. The following is a simpler way of writing the
- last `*' example:
-
- awk '/\(c[ad]+r x\)/ { print }' sample
+ match all three.
`?'
This symbol is similar to `*', except that the preceding
@@ -3604,7 +3634,7 @@ list".
regexp operator or function.

-File: gawk.info, Node: Bracket Expressions, Next: GNU Regexp Operators, Prev: Regexp Operators, Up: Regexp
+File: gawk.info, Node: Bracket Expressions, Next: Leftmost Longest, Prev: Regexp Operators, Up: Regexp
3.4 Using Bracket Expressions
=============================
@@ -3625,10 +3655,12 @@ expression, put a `\' in front of it. For example:
[d\]]
-matches either `d' or `]'.
+matches either `d' or `]'. Additionally, if you place `]' right after
+the opening `[', the closing bracket is treated as one of the
+characters to be matched.
- This treatment of `\' in bracket expressions is compatible with
-other `awk' implementations and is also mandated by POSIX. The regular
+ 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.
@@ -3707,9 +3739,119 @@ Equivalence classes
classes.

-File: gawk.info, Node: GNU Regexp Operators, Next: Case-sensitivity, Prev: Bracket Expressions, Up: Regexp
+File: gawk.info, Node: Leftmost Longest, Next: Computed Regexps, Prev: Bracket Expressions, Up: Regexp
+
+3.5 How Much Text Matches?
+==========================
+
+Consider the following:
+
+ echo aaaabcd | awk '{ sub(/a+/, "<A>"); print }'
+
+ 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
+characters that can match. Thus, all four `a' characters are replaced
+with `<A>' in this example:
+
+ $ echo aaaabcd | awk '{ sub(/a+/, "<A>"); print }'
+ -| <A>bcd
+
+ For simple match/no-match tests, this is not so important. But when
+doing text matching and substitutions with the `match()', `sub()',
+`gsub()', and `gensub()' functions, it is very important. *Note String
+Functions::, for more information on these functions. Understanding
+this principle is also important for regexp-based record and field
+splitting (*note Records::, and also *note Field Separators::).
+
+
+File: gawk.info, Node: Computed Regexps, Next: GNU Regexp Operators, Prev: Leftmost Longest, Up: Regexp
+
+3.6 Using Dynamic Regexps
+=========================
+
+The righthand side of a `~' or `!~' operator need not be a regexp
+constant (i.e., a string of characters between slashes). It may be any
+expression. The expression is evaluated and converted to a string if
+necessary; the contents of the string are then used as the regexp. A
+regexp computed in this way is called a "dynamic regexp" or a "computed
+regexp":
+
+ BEGIN { digits_regexp = "[[:digit:]]+" }
+ $0 ~ digits_regexp { print }
+
+This sets `digits_regexp' to a regexp that describes one or more digits,
+and tests whether the input record matches this regexp.
+
+ NOTE: When using the `~' and `!~' operators, there is a difference
+ between a regexp constant enclosed in slashes and a string
+ constant enclosed in double quotes. If you are going to use a
+ string constant, you have to understand that the string is, in
+ essence, scanned _twice_: the first time when `awk' reads your
+ program, and the second time when it goes to match the string on
+ the lefthand side of the operator with the pattern on the right.
+ This is true of any string-valued expression (such as
+ `digits_regexp', shown previously), not just string constants.
+
+ What difference does it make if the string is scanned twice? The
+answer has to do with escape sequences, and particularly with
+backslashes. To get a backslash into a regular expression inside a
+string, you have to type two backslashes.
+
+ For example, `/\*/' is a regexp constant for a literal `*'. Only
+one backslash is needed. To do the same thing with a string, you have
+to type `"\\*"'. The first backslash escapes the second one so that
+the string actually contains the two characters `\' and `*'.
+
+ Given that you can use both regexp and string constants to describe
+regular expressions, which should you use? The answer is "regexp
+constants," for several reasons:
+
+ * String constants are more complicated to write and more difficult
+ to read. Using regexp constants makes your programs less
+ error-prone. Not understanding the difference between the two
+ kinds of constants is a common source of errors.
+
+ * It is more efficient to use regexp constants. `awk' can note that
+ you have supplied a regexp and store it internally in a form that
+ makes pattern matching more efficient. When using a string
+ constant, `awk' must first convert the string into this internal
+ form and then perform the pattern matching.
+
+ * Using regexp constants is better form; it shows clearly that you
+ intend a regexp match.
+
+ Using `\n' in Bracket Expressions of Dynamic Regexps
+
+ 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--> $0 ~ "[ >>> \t\n]" <<<
+
+ But a newline in a regexp constant works with no problem:
+
+ $ awk '$0 ~ /[ \t\n]/'
+ here is a sample line
+ -| here is a sample line
+ Ctrl-d
+
+ `gawk' does not have this problem, and it isn't likely to occur
+often in practice, but it's worth noting for future reference.
+
+
+File: gawk.info, Node: GNU Regexp Operators, Next: Case-sensitivity, Prev: Computed Regexps, Up: Regexp
-3.5 `gawk'-Specific Regexp Operators
+3.7 `gawk'-Specific Regexp Operators
====================================
GNU software that deals with regular expressions provides a number of
@@ -3793,7 +3935,7 @@ No options
Traditional Unix `awk' regexps are matched. The GNU operators are
not special, and interval expressions are not available. The
POSIX character classes (`[[:alnum:]]', etc.) are supported, as
- BWK `awk' does support them. Characters described by octal and
+ BWK `awk' supports them. Characters described by octal and
hexadecimal escape sequences are treated literally, even if they
represent regexp metacharacters.
@@ -3803,9 +3945,9 @@ No options
default.

-File: gawk.info, Node: Case-sensitivity, Next: Leftmost Longest, Prev: GNU Regexp Operators, Up: Regexp
+File: gawk.info, Node: Case-sensitivity, Next: Regexp Summary, Prev: GNU Regexp Operators, Up: Regexp
-3.6 Case Sensitivity in Matching
+3.8 Case Sensitivity in Matching
================================
Case is normally significant in regular expressions, both when matching
@@ -3878,116 +4020,7 @@ obscure and we don't recommend it.
means that `gawk' does the right thing.

-File: gawk.info, Node: Leftmost Longest, Next: Computed Regexps, Prev: Case-sensitivity, Up: Regexp
-
-3.7 How Much Text Matches?
-==========================
-
-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>'.
-
- The input contains four `a' characters. `awk' (and POSIX) regular
-expressions always match the leftmost, _longest_ sequence of input
-characters that can match. Thus, all four `a' characters are replaced
-with `<A>' in this example:
-
- $ echo aaaabcd | awk '{ sub(/a+/, "<A>"); print }'
- -| <A>bcd
-
- For simple match/no-match tests, this is not so important. But when
-doing text matching and substitutions with the `match()', `sub()',
-`gsub()', and `gensub()' functions, it is very important. *Note String
-Functions::, for more information on these functions. Understanding
-this principle is also important for regexp-based record and field
-splitting (*note Records::, and also *note Field Separators::).
-
-
-File: gawk.info, Node: Computed Regexps, Next: Regexp Summary, Prev: Leftmost Longest, Up: Regexp
-
-3.8 Using Dynamic Regexps
-=========================
-
-The righthand side of a `~' or `!~' operator need not be a regexp
-constant (i.e., a string of characters between slashes). It may be any
-expression. The expression is evaluated and converted to a string if
-necessary; the contents of the string are then used as the regexp. A
-regexp computed in this way is called a "dynamic regexp" or a "computed
-regexp":
-
- BEGIN { digits_regexp = "[[:digit:]]+" }
- $0 ~ digits_regexp { print }
-
-This sets `digits_regexp' to a regexp that describes one or more digits,
-and tests whether the input record matches this regexp.
-
- NOTE: When using the `~' and `!~' operators, there is a difference
- between a regexp constant enclosed in slashes and a string
- constant enclosed in double quotes. If you are going to use a
- string constant, you have to understand that the string is, in
- essence, scanned _twice_: the first time when `awk' reads your
- program, and the second time when it goes to match the string on
- the lefthand side of the operator with the pattern on the right.
- This is true of any string-valued expression (such as
- `digits_regexp', shown previously), not just string constants.
-
- What difference does it make if the string is scanned twice? The
-answer has to do with escape sequences, and particularly with
-backslashes. To get a backslash into a regular expression inside a
-string, you have to type two backslashes.
-
- For example, `/\*/' is a regexp constant for a literal `*'. Only
-one backslash is needed. To do the same thing with a string, you have
-to type `"\\*"'. The first backslash escapes the second one so that
-the string actually contains the two characters `\' and `*'.
-
- Given that you can use both regexp and string constants to describe
-regular expressions, which should you use? The answer is "regexp
-constants," for several reasons:
-
- * String constants are more complicated to write and more difficult
- to read. Using regexp constants makes your programs less
- error-prone. Not understanding the difference between the two
- kinds of constants is a common source of errors.
-
- * It is more efficient to use regexp constants. `awk' can note that
- you have supplied a regexp and store it internally in a form that
- makes pattern matching more efficient. When using a string
- constant, `awk' must first convert the string into this internal
- form and then perform the pattern matching.
-
- * Using regexp constants is better form; it shows clearly that you
- intend a regexp match.
-
- 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:
-
- $ awk '$0 ~ "[ \t\n]"'
- error--> awk: newline in character class [
- error--> ]...
- error--> source line number 1
- error--> context is
- error--> >>> <<<
-
- But a newline in a regexp constant works with no problem:
-
- $ awk '$0 ~ /[ \t\n]/'
- here is a sample line
- -| here is a sample line
- Ctrl-d
-
- `gawk' does not have this problem, and it isn't likely to occur
-often in practice, but it's worth noting for future reference.
-
-
-File: gawk.info, Node: Regexp Summary, Prev: Computed Regexps, Up: Regexp
+File: gawk.info, Node: Regexp Summary, Prev: Case-sensitivity, Up: Regexp
3.9 Summary
===========
@@ -4011,18 +4044,18 @@ File: gawk.info, Node: Regexp Summary, Prev: Computed Regexps, 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
record separator is a regexp.
- * Matching expressions may use dynamic regexps; that is, string
+ * Matching expressions may use dynamic regexps, that is, string
values treated as regular expressions.
+ * `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
@@ -4035,8 +4068,8 @@ standard input (by default, this is the keyboard, but often it is a
pipe from another command) or from files whose names you specify on the
`awk' command line. If you specify input files, `awk' reads them in
order, processing all the data from one before going on to the next.
-The name of the current input file can be found in the built-in variable
-`FILENAME' (*note Built-in Variables::).
+The name of the current input file can be found in the predefined
+variable `FILENAME' (*note Built-in Variables::).
The input is read in units called "records", and is processed by the
rules of your program one record at a time. By default, each record is
@@ -4073,13 +4106,13 @@ File: gawk.info, Node: Records, Next: Fields, Up: Reading Files
4.1 How Input Is Split into Records
===================================
-The `awk' utility divides the input for your `awk' program into records
-and fields. `awk' keeps track of the number of records that have been
-read so far from the current input file. This value is stored in a
-built-in variable called `FNR'. It is reset to zero when a new file is
-started. Another built-in variable, `NR', records the total number of
-input records read so far from all data files. It starts at zero, but
-is never automatically reset to zero.
+`awk' divides the input for your program into records and fields. It
+keeps track of the number of records that have been read so far from
+the current input file. This value is stored in a predefined variable
+called `FNR' which is reset to zero every time a new file is started.
+Another predefined variable, `NR', records the total number of input
+records read so far from all data files. It starts at zero, but is
+never automatically reset to zero.
* Menu:
@@ -4096,7 +4129,7 @@ Records are separated by a character called the "record separator". By
default, the record separator is the newline character. This is why
records are, by default, single lines. A different character can be
used for the record separator by assigning the character to the
-built-in variable `RS'.
+predefined variable `RS'.
Like any other variable, the value of `RS' can be changed in the
`awk' program with the assignment operator, `=' (*note Assignment
@@ -4184,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
@@ -4251,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
@@ -4268,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
@@ -4303,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 ----------
@@ -4346,7 +4381,7 @@ Here the first field, or `$1', is `This', the second field, or `$2', is
Because there is no space between the `e' and the `.', the period is
considered part of the seventh field.
- `NF' is a built-in variable whose value is the number of fields in
+ `NF' is a predefined variable whose value is the number of fields in
the current record. `awk' automatically updates the value of `NF' each
time it reads a record. No matter how many fields there are, the last
field in a record can be represented by `$NF'. So, `$NF' is the same
@@ -4364,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
@@ -4425,9 +4458,9 @@ program. Other `awk' implementations may behave differently.)
As mentioned in *note Fields::, `awk' stores the current record's
number of fields in the built-in variable `NF' (also *note Built-in
-Variables::). The expression `$NF' is not a special feature--it is the
-direct consequence of evaluating `NF' and using its value as a field
-number.
+Variables::). Thus, the expression `$NF' is not a special feature--it
+is the direct consequence of evaluating `NF' and using its value as a
+field number.
---------- Footnotes ----------
@@ -4546,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
@@ -4576,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
@@ -4614,7 +4647,7 @@ the following line:
is split into three fields: `m', `*g', and `*gai*pan'. Note the
leading spaces in the values of the second and third fields.
- The field separator is represented by the built-in variable `FS'.
+ The field separator is represented by the predefined variable `FS'.
Shell programmers take note: `awk' does _not_ use the name `IFS' that
is used by the POSIX-compliant shells (such as the Unix Bourne shell,
`sh', or Bash).
@@ -4727,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
@@ -4744,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<--
@@ -4789,13 +4822,10 @@ 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
+same way as assignments to the predefined variable `FS'. Any special
characters in the field separator must be escaped appropriately. For
example, to use a `\' as the field separator on the command line, you
would have to type:
@@ -4890,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 == " "'
@@ -4910,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
@@ -5281,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"'
@@ -5305,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 ----------
@@ -5334,8 +5365,8 @@ yet. Therefore, come back and study the `getline' command _after_ you
have reviewed the rest of this Info file and have a good knowledge of
how `awk' works.
- The `getline' command returns one if it finds a record and zero if
-it encounters the end of the file. If there is some error in getting a
+ The `getline' command returns 1 if it finds a record and 0 if it
+encounters the end of the file. If there is some error in getting a
record, such as a file that cannot be opened, then `getline' returns
-1. In this case, `gawk' sets the variable `ERRNO' to a string
describing the error that occurred.
@@ -5374,35 +5405,45 @@ input record and split it up into fields. This is useful if you've
finished processing the current record, but want to do some special
processing on the next record _right now_. For example:
+ # Remove text between /* and */, inclusive
{
- if ((t = index($0, "/*")) != 0) {
- # value of `tmp' will be "" if t is 1
- tmp = substr($0, 1, t - 1)
- u = index(substr($0, t + 2), "*/")
- offset = t + 2
- while (u == 0) {
- if (getline <= 0) {
- m = "unexpected EOF or error"
- m = (m ": " ERRNO)
- print m > "/dev/stderr"
+ if ((i = index($0, "/*")) != 0) {
+ out = substr($0, 1, i - 1) # leading part of the string
+ rest = substr($0, i + 2) # ... */ ...
+ j = index(rest, "*/") # is */ in trailing part?
+ if (j > 0) {
+ rest = substr(rest, j + 2) # remove comment
+ } else {
+ while (j == 0) {
+ # get more text
+ if (getline <= 0) {
+ print("unexpected EOF or error:", ERRNO) > "/dev/stderr"
exit
- }
- u = index($0, "*/")
- offset = 0
- }
- # substr() expression will be "" if */
- # occurred at end of line
- $0 = tmp substr($0, offset + u + 2)
- }
- print $0
+ }
+ # build up the line using string concatenation
+ rest = rest $0
+ j = index(rest, "*/") # is */ in trailing part?
+ if (j != 0) {
+ rest = substr(rest, j + 2)
+ break
+ }
+ }
+ }
+ # build up the output line using string concatenation
+ $0 = out rest
+ }
+ print $0
}
This `awk' program deletes C-style comments (`/* ... */') from the
-input. By replacing the `print $0' with other statements, you could
-perform more complicated processing on the decommented input, such as
-searching for matches of a regular expression. (This program has a
-subtle problem--it does not work if one comment ends and another begins
-on the same line.)
+input. It uses a number of features we haven't covered yet, including
+string concatenation (*note Concatenation::) and the `index()' and
+`substr()' built-in functions (*note String Functions::). By replacing
+the `print $0' with other statements, you could perform more
+complicated processing on the decommented input, such as searching for
+matches of a regular expression. (This program has a subtle
+problem--it does not work if one comment ends and another begins on the
+same line.)
This form of the `getline' command sets `NF', `NR', `FNR', `RT', and
the value of `$0'.
@@ -5498,7 +5539,7 @@ Use `getline VAR < FILE' to read input from the file FILE, and put it
in the variable VAR. As above, FILE is a string-valued expression that
specifies the file from which to read.
- In this version of `getline', none of the built-in variables are
+ In this version of `getline', none of the predefined variables are
changed and the record is not split into fields. The only variable
changed is VAR.(1) For example, the following program copies all the
input files to the output, except for records that say
@@ -5579,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'
@@ -5597,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
@@ -5619,8 +5660,8 @@ following program reads the current date and time into the variable
print "Report printed on " current_time
}
- In this version of `getline', none of the built-in variables are
-changed and the record is not split into fields.
+ In this version of `getline', none of the predefined variables are
+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
@@ -5669,7 +5710,7 @@ When you use `COMMAND |& getline VAR', the output from the coprocess
COMMAND is sent through a two-way pipe to `getline' and into the
variable VAR.
- In this version of `getline', none of the built-in variables are
+ In this version of `getline', none of the predefined variables are
changed and the record is not split into fields. The only variable
changed is VAR. However, `RT' is set.
@@ -5702,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
@@ -5735,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
@@ -5744,23 +5785,22 @@ File: gawk.info, Node: Getline Summary, Prev: Getline Notes, Up: Getline
------------------------------------
*note table-getline-variants:: summarizes the eight variants of
-`getline', listing which built-in variables are set by each one, and
+`getline', listing which predefined variables are set by each one, and
whether the variant is standard or a `gawk' extension. Note: for each
-variant, `gawk' sets the `RT' built-in variable.
+variant, `gawk' sets the `RT' predefined 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
@@ -5776,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
@@ -5800,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
@@ -5900,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
@@ -5917,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.
@@ -5966,8 +6009,8 @@ File: gawk.info, Node: Input Exercises, Prev: Input Summary, Up: Reading File
2. *note Plain Getline::, presented a program to remove C-style
comments (`/* ... */') from the input. That program does not work
if one comment ends on one line and another one starts later on
- the same line. Write a program that does handle multiple comments
- on the line.
+ the same line. That can be fixed by making one simple change.
+ What is it?

@@ -6000,12 +6043,13 @@ function.
* Printf:: The `printf' statement.
* Redirection:: How to redirect output to multiple files and
pipes.
+* Special FD:: Special files for I/O.
* Special Files:: File name interpretation in `gawk'.
`gawk' allows access to inherited file
descriptors.
* Close Files And Pipes:: Closing Input and Output Files and Pipes.
* Output Summary:: Output summary.
-* Output exercises:: Exercises.
+* Output Exercises:: Exercises.

File: gawk.info, Node: Print, Next: Print Examples, Up: Printing
@@ -6013,10 +6057,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, ...
@@ -6031,14 +6075,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.

@@ -6131,7 +6175,7 @@ As mentioned previously, a `print' statement contains a list of items
separated by commas. In the output, the items are normally separated
by single spaces. However, this doesn't need to be the case; a single
space is simply the default. Any string of characters may be used as
-the "output field separator" by setting the built-in variable `OFS'.
+the "output field separator" by setting the predefined variable `OFS'.
The initial value of this variable is the string `" "'--that is, a
single space.
@@ -6193,12 +6237,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 predefined 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)
@@ -6220,8 +6264,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:
@@ -6240,10 +6282,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
@@ -6264,10 +6306,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.
@@ -6285,9 +6327,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'
@@ -6380,7 +6422,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:
@@ -6400,8 +6442,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
@@ -6431,10 +6472,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
@@ -6582,14 +6623,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
@@ -6601,10 +6642,10 @@ 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
+File: gawk.info, Node: Redirection, Next: Special FD, Prev: Printf, Up: Printing
5.6 Redirecting Output of `print' and `printf'
==============================================
@@ -6614,7 +6655,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
@@ -6685,16 +6726,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.
@@ -6760,40 +6795,30 @@ uppercase characters converted to lowercase (*note String Functions::).
The program builds up a list of command lines, using the `mv' utility
to rename the files. It then sends the list to the shell for execution.
-
-File: gawk.info, Node: Special Files, Next: Close Files And Pipes, Prev: Redirection, Up: Printing
-
-5.7 Special File Names in `gawk'
-================================
-
-`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.
-
-* Menu:
-
-* Special FD:: Special files for I/O.
-* Special Network:: Special files for network communications.
-* Special Caveats:: Things to watch out for.
+ *Note Shell Quoting::, for a function that can help in generating
+command lines to be fed to the shell.

-File: gawk.info, Node: Special FD, Next: Special Network, Up: Special Files
+File: gawk.info, Node: Special FD, Next: Special Files, Prev: Redirection, Up: Printing
-5.7.1 Special Files for Standard Descriptors
---------------------------------------------
+5.7 Special Files for Standard Pre-Opened Data Streams
+======================================================
Running programs conventionally have three input and output streams
already available to them for reading and writing. These are known as
the "standard input", "standard output", and "standard error output".
-These streams are, by default, connected to your keyboard and screen,
-but they are often redirected with the shell, via the `<', `<<', `>',
-`>>', `>&', and `|' operators. Standard error is typically used for
-writing error messages; the reason there are two separate streams,
+These open streams (and any other open file or pipe) are often referred
+to by the technical term "file descriptors".
+
+ These streams are, by default, connected to your keyboard and
+screen, but they are often redirected with the shell, via the `<', `<<',
+`>', `>>', `>&', and `|' operators. Standard error is typically used
+for writing error messages; the reason there are two separate streams,
standard output and standard error, is so that they can be redirected
separately.
- In other implementations of `awk', the only way to write an error
-message to standard error in an `awk' program is as follows:
+ In traditional implementations of `awk', the only way to write an
+error message to standard error in an `awk' program is as follows:
print "Serious error detected!" | "cat 1>&2"
@@ -6808,19 +6833,18 @@ 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:
+ `gawk', BWK `awk' and `mawk' provide special file names for
+accessing the three standard streams. If the file name matches one of
+these special names when `gawk' (or one of the others) 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).
@@ -6831,16 +6855,8 @@ those that are POSIX-compliant:
`/dev/stderr'
The standard error output (file descriptor 2).
-`/dev/fd/N'
- The file associated with file descriptor N. Such a file must be
- opened by the program initiating the `awk' execution (typically
- the shell). Unless special pains are taken in the shell from which
- `gawk' is invoked, only descriptors 0, 1, and 2 are available.
-
- The file names `/dev/stdin', `/dev/stdout', and `/dev/stderr' are
-aliases for `/dev/fd/0', `/dev/fd/1', and `/dev/fd/2', respectively.
-However, they are more self-explanatory. The proper way to write an
-error message in a `gawk' program is to use `/dev/stderr', like this:
+ With these facilities, the proper way to write an error message then
+becomes:
print "Serious error detected!" > "/dev/stderr"
@@ -6848,21 +6864,60 @@ error message in a `gawk' program is to use `/dev/stderr', like this:
redirection, the value must be a string. It is a common error to omit
the quotes, which leads to confusing results.
- Finally, using the `close()' function on a file name of the form
-`"/dev/fd/N"', for file descriptor numbers above two, does actually
-close the given file descriptor.
-
- The `/dev/stdin', `/dev/stdout', and `/dev/stderr' special files are
-also recognized internally by several other versions of `awk'.
+ `gawk' does not treat these file names as special when in POSIX
+compatibility mode. However, since BWK `awk' supports them, `gawk' does
+support them even when invoked with the `--traditional' option (*note
+Options::).
---------- Footnotes ----------
(1) The "tty" in `/dev/tty' stands for "Teletype," a serial terminal.

-File: gawk.info, Node: Special Network, Next: Special Caveats, Prev: Special FD, Up: Special Files
+File: gawk.info, Node: Special Files, Next: Close Files And Pipes, Prev: Special FD, Up: Printing
+
+5.8 Special File Names in `gawk'
+================================
+
+Besides access to standard input, stanard output, and standard error,
+`gawk' provides access to any open file descriptor. Additionally,
+there are special file names reserved for TCP/IP networking.
+
+* Menu:
+
+* Other Inherited Files:: Accessing other open files with
+ `gawk'.
+* Special Network:: Special files for network communications.
+* Special Caveats:: Things to watch out for.
+
+
+File: gawk.info, Node: Other Inherited Files, Next: Special Network, Up: Special Files
+
+5.8.1 Accessing Other Open Files With `gawk'
+--------------------------------------------
+
+Besides the `/dev/stdin', `/dev/stdout', and `/dev/stderr' special file
+names mentioned earlier, `gawk' provides syntax for accessing any other
+inherited open file:
+
+`/dev/fd/N'
+ The file associated with file descriptor N. Such a file must be
+ opened by the program initiating the `awk' execution (typically
+ the shell). Unless special pains are taken in the shell from which
+ `gawk' is invoked, only descriptors 0, 1, and 2 are available.
-5.7.2 Special Files for Network Communications
+ The file names `/dev/stdin', `/dev/stdout', and `/dev/stderr' are
+essentially aliases for `/dev/fd/0', `/dev/fd/1', and `/dev/fd/2',
+respectively. However, those names are more self-explanatory.
+
+ Note that using `close()' on a file name of the form `"/dev/fd/N"',
+for file descriptor numbers above two, does actually close the given
+file descriptor.
+
+
+File: gawk.info, Node: Special Network, Next: Special Caveats, Prev: Other Inherited Files, Up: Special Files
+
+5.8.2 Special Files for Network Communications
----------------------------------------------
`gawk' programs can open a two-way TCP/IP connection, acting as either
@@ -6882,14 +6937,18 @@ mentioned here only for completeness. Full discussion is delayed until

File: gawk.info, Node: Special Caveats, Prev: Special Network, Up: Special Files
-5.7.3 Special File Name Caveats
+5.8.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::).
+ * Recognition of the file names for the three standard pre-opened
+ files is disabled only in POSIX mode.
+
+ * Recognition of the other special file names is disabled if `gawk'
+ is in compatibility mode (either `--traditional' or `--posix';
+ *note Options::).
* `gawk' _always_ interprets these special file names. For example,
using `/dev/fd/4' for output actually writes on file descriptor 4,
@@ -6902,7 +6961,7 @@ names that `gawk' provides:

File: gawk.info, Node: Close Files And Pipes, Next: Output Summary, Prev: Special Files, Up: Printing
-5.8 Closing Input and Output Redirections
+5.9 Closing Input and Output Redirections
=========================================
If the same file name or the same shell command is used with `getline'
@@ -7016,7 +7075,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
@@ -7025,8 +7085,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
@@ -7041,8 +7101,8 @@ value from `close()': (d.c.)
`gawk' treats `close()' as a function. The return value is -1 if
the argument names something that was never opened with a redirection,
or if there is a system problem closing the file or process. In these
-cases, `gawk' sets the built-in variable `ERRNO' to a string describing
-the problem.
+cases, `gawk' sets the predefined variable `ERRNO' to a string
+describing the problem.
In `gawk', when closing a pipe or coprocess (input or output), the
return value is the exit status of the command.(2) Otherwise, it is the
@@ -7067,10 +7127,10 @@ call. See the system manual pages for information on how to decode this
value.

-File: gawk.info, Node: Output Summary, Next: Output exercises, Prev: Close Files And Pipes, Up: Printing
+File: gawk.info, Node: Output Summary, Next: Output Exercises, Prev: Close Files And Pipes, Up: Printing
-5.9 Summary
-===========
+5.10 Summary
+============
* The `print' statement prints comma-separated expressions. Each
expression is separated by the value of `OFS' and terminated by
@@ -7082,20 +7142,20 @@ 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.

-File: gawk.info, Node: Output exercises, Prev: Output Summary, Up: Printing
+File: gawk.info, Node: Output Exercises, Prev: Output Summary, Up: Printing
-5.10 Exercises
+5.11 Exercises
==============
1. Rewrite the program:
@@ -7298,8 +7358,9 @@ File: gawk.info, Node: Regexp Constants, Prev: Nondecimal-numbers, Up: Consta
A regexp constant is a regular expression description enclosed in
slashes, such as `/^beginning and end$/'. Most regexps used in `awk'
programs are constant, but the `~' and `!~' matching operators can also
-match computed or dynamic regexps (which are just ordinary strings or
-variables that contain a regexp).
+match computed or dynamic regexps (which are typically just ordinary
+strings or variables that contain a regexp, but could be a more complex
+expression).

File: gawk.info, Node: Using Constant Regexps, Next: Variables, Prev: Constants, Up: Values
@@ -7324,7 +7385,7 @@ and:
are exactly equivalent. One rather bizarre consequence of this rule is
that the following Boolean expression is valid, but does not do what
-the user probably intended:
+its author probably intended:
# Note that /foo/ is on the left of the ~
if (/foo/ ~ $1) print "found foo"
@@ -7350,9 +7411,10 @@ of the `match()' function, and as the third argument of the `split()'
and `patsplit()' functions (*note String Functions::). Modern
implementations of `awk', including `gawk', allow the third argument of
`split()' to be a regexp constant, but some older implementations do
-not. (d.c.) This can lead to confusion when attempting to use regexp
-constants as arguments to user-defined functions (*note User-defined::).
-For example:
+not. (d.c.) Because some built-in functions accept regexp constants
+as arguments, it can be confusing when attempting to use regexp
+constants as arguments to user-defined functions (*note
+User-defined::). For example:
function mysub(pat, repl, str, global)
{
@@ -7405,31 +7467,34 @@ File: gawk.info, Node: Using Variables, Next: Assignment Options, Up: Variabl
Variables let you give names to values and refer to them later.
Variables have already been used in many of the examples. The name of
a variable must be a sequence of letters, digits, or underscores, and
-it may not begin with a digit. Case is significant in variable names;
-`a' and `A' are distinct variables.
+it may not begin with a digit. Here, a "letter" is any one of the 52
+upper- and lowercase English letters. Other characters that may be
+defined as letters in non-English locales are not valid in variable
+names. Case is significant in variable names; `a' and `A' are distinct
+variables.
A variable name is a valid expression by itself; it represents the
variable's current value. Variables are given new values with
"assignment operators", "increment operators", and "decrement
operators". *Note Assignment Ops::. In addition, the `sub()' and
`gsub()' functions can change a variable's value, and the `match()',
-`patsplit()' and `split()' functions can change the contents of their
+`split()' and `patsplit()' functions can change the contents of their
array parameters. *Note String Functions::.
A few variables have special built-in meanings, such as `FS' (the
field separator), and `NF' (the number of fields in the current input
-record). *Note Built-in Variables::, for a list of the built-in
-variables. These built-in variables can be used and assigned just like
-all other variables, but their values are also used or changed
-automatically by `awk'. All built-in variables' names are entirely
+record). *Note Built-in Variables::, for a list of the predefined
+variables. These predefined variables can be used and assigned just
+like all other variables, but their values are also used or changed
+automatically by `awk'. All predefined variables' names are entirely
uppercase.
Variables in `awk' can be assigned either numeric or string values.
The kind of value a variable holds can change over the life of a
program. By default, variables are initialized to the empty string,
which is zero if converted to a number. There is no need to explicitly
-"initialize" a variable in `awk', which is what you would do in C and
-in most other traditional languages.
+initialize a variable in `awk', which is what you would do in C and in
+most other traditional languages.

File: gawk.info, Node: Assignment Options, Prev: Using Variables, Up: Variables
@@ -7525,7 +7590,7 @@ the string as numerals: `"2.5"' converts to 2.5, `"1e3"' converts to
interpreted as valid numbers convert to zero.
The exact manner in which numbers are converted into strings is
-controlled by the `awk' built-in variable `CONVFMT' (*note Built-in
+controlled by the `awk' predefined variable `CONVFMT' (*note Built-in
Variables::). Numbers are converted using the `sprintf()' function
with `CONVFMT' as the format specifier (*note String Functions::).
@@ -7604,8 +7669,8 @@ difference in behavior, on a GNU/Linux system:
The `en_DK.utf-8' locale is for English in Denmark, where the comma
acts as the decimal point separator. In the normal `"C"' locale, `gawk'
-treats `4,321' as `4', while in the Danish locale, it's treated as the
-full number, 4.321.
+treats `4,321' as 4, while in the Danish locale, it's treated as the
+full number including the fractional part, 4.321.
Some earlier versions of `gawk' fully complied with this aspect of
the standard. However, many users in non-English locales complained
@@ -7987,8 +8052,7 @@ A workaround is:
awk '/[=]=/' /dev/null
- `gawk' does not have this problem; BWK `awk' and `mawk' also do not
-(*note Other Versions::).
+ `gawk' does not have this problem; BWK `awk' and `mawk' also do not.

File: gawk.info, Node: Increment Ops, Prev: Assignment Ops, Up: All Operators
@@ -8165,9 +8229,9 @@ determine how they are compared. Variable typing follows these rules:
STRING attribute.
* Fields, `getline' input, `FILENAME', `ARGV' elements, `ENVIRON'
- elements, and the elements of an array created by `patsplit()',
- `split()' and `match()' that are numeric strings have the STRNUM
- attribute. Otherwise, they have the STRING attribute.
+ elements, and the elements of an array created by `match()',
+ `split()' and `patsplit()' that are numeric strings have the
+ STRNUM attribute. Otherwise, they have the STRING attribute.
Uninitialized variables also have the STRNUM attribute.
* Attributes propagate across assignments but are not changed by any
@@ -8217,21 +8281,21 @@ In contrast, the eight characters `" +3.14"' appearing in program text
comprise a string constant. The following examples print `1' when the
comparison between the two different constants is true, `0' otherwise:
- $ echo ' +3.14' | gawk '{ print $0 == " +3.14" }' True
+ $ echo ' +3.14' | awk '{ print($0 == " +3.14") }' True
-| 1
- $ echo ' +3.14' | gawk '{ print $0 == "+3.14" }' False
+ $ echo ' +3.14' | awk '{ print($0 == "+3.14") }' False
-| 0
- $ echo ' +3.14' | gawk '{ print $0 == "3.14" }' False
+ $ echo ' +3.14' | awk '{ print($0 == "3.14") }' False
-| 0
- $ echo ' +3.14' | gawk '{ print $0 == 3.14 }' True
+ $ echo ' +3.14' | awk '{ print($0 == 3.14) }' True
-| 1
- $ echo ' +3.14' | gawk '{ print $1 == " +3.14" }' False
+ $ echo ' +3.14' | awk '{ print($1 == " +3.14") }' False
-| 0
- $ echo ' +3.14' | gawk '{ print $1 == "+3.14" }' True
+ $ echo ' +3.14' | awk '{ print($1 == "+3.14") }' True
-| 1
- $ echo ' +3.14' | gawk '{ print $1 == "3.14" }' False
+ $ echo ' +3.14' | awk '{ print($1 == "3.14") }' False
-| 0
- $ echo ' +3.14' | gawk '{ print $1 == 3.14 }' True
+ $ echo ' +3.14' | awk '{ print($1 == 3.14) }' True
-| 1

@@ -8284,8 +8348,9 @@ 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
-`gawk' performs, as well as what the result of the comparison is:
+ The following list of expressions illustrates the kinds of
+comparisons `awk' performs, as well as what the result of each
+comparison is:
`1.5 <= 2.0'
numeric comparison (true)
@@ -8336,9 +8401,9 @@ regexp constant (`/'...`/') or an ordinary expression. In the latter
case, the value of the expression as a string is used as a dynamic
regexp (*note Regexp Usage::; also *note Computed Regexps::).
- In modern implementations of `awk', a constant regular expression in
-slashes by itself is also an expression. The regexp `/REGEXP/' is an
-abbreviation for the following comparison expression:
+ A constant regular expression in slashes by itself is also an
+expression. The regexp `/REGEXP/' is an abbreviation for the following
+comparison expression:
$0 ~ /REGEXP/
@@ -8354,9 +8419,9 @@ File: gawk.info, Node: POSIX String Comparison, Prev: Comparison Operators, U
The POSIX standard says that string comparison is performed based on
the locale's "collating order". This is the order in which characters
-sort, as defined by the locale (for more discussion, *note Ranges and
-Locales::). This order is usually very different from the results
-obtained when doing straight character-by-character comparison.(1)
+sort, as defined by the locale (for more discussion, *note Locales::).
+This order is usually very different from the results obtained when
+doing straight character-by-character comparison.(1)
Because this behavior differs considerably from existing practice,
`gawk' only implements it when in POSIX mode (*note Options::). Here
@@ -8413,13 +8478,15 @@ Boolean operators are:
`BOOLEAN1 || BOOLEAN2'
True if at least one of BOOLEAN1 or BOOLEAN2 is true. For
example, the following statement prints all records in the input
- that contain _either_ `edu' or `li' or both:
+ that contain _either_ `edu' or `li':
if ($0 ~ /edu/ || $0 ~ /li/) print
The subexpression BOOLEAN2 is evaluated only if BOOLEAN1 is false.
This can make a difference when BOOLEAN2 contains expressions that
- have side effects.
+ have side effects. (Thus, this test never really distinguishes
+ records that contain both `edu' and `li'--as soon as `edu' is
+ matched, the full test succeeds.)
`! BOOLEAN'
True if BOOLEAN is false. For example, the following program
@@ -8427,7 +8494,7 @@ Boolean operators are:
variable is not defined:
BEGIN { if (! ("HOME" in ENVIRON))
- print "no home!" }
+ print "no home!" }
(The `in' operator is described in *note Reference to Elements::.)
@@ -8436,9 +8503,9 @@ because of the way they work. Evaluation of the full expression is
"short-circuited" if the result can be determined part way through its
evaluation.
- Statements that use `&&' or `||' can be continued simply by putting
-a newline after them. But you cannot put a newline in front of either
-of these operators without using backslash continuation (*note
+ Statements that end with `&&' or `||' can be continued simply by
+putting a newline after them. But you cannot put a newline in front of
+either of these operators without using backslash continuation (*note
Statements/Lines::).
The actual value of an expression using the `!' operator is either
@@ -8449,7 +8516,7 @@ following program is one way to print lines in between special
bracketing lines:
$1 == "START" { interested = ! interested; next }
- interested == 1 { print }
+ interested { print }
$1 == "END" { interested = ! interested; next }
The variable `interested', as with all `awk' variables, starts out
@@ -8459,6 +8526,14 @@ using `!'. The next rule prints lines as long as `interested' is true.
When a line is seen whose first field is `END', `interested' is toggled
back to false.(1)
+ Most commonly, the `!' operator is used in the conditions of `if'
+and `while' statements, where it often makes more sense to phrase the
+logic in the negative:
+
+ if (! SOME CONDITION || SOME OTHER CONDITION) {
+ ... DO WHATEVER PROCESSING ...
+ }
+
NOTE: The `next' statement is discussed in *note Next Statement::.
`next' tells `awk' to skip the rest of the rules, get the next
record, and start processing the rules over again at the top. The
@@ -8642,7 +8717,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:
`('...`)'
@@ -8717,8 +8792,8 @@ system about the local character set and language. The ISO C standard
defines a default `"C"' locale, which is an environment that is typical
of what many C programmers are used to.
- Once upon a time, the locale setting used to affect regexp matching
-(*note Ranges and Locales::), but this is no longer true.
+ Once upon a time, the locale setting used to affect regexp matching,
+but this is no longer true (*note Ranges and Locales::).
Locales can affect record splitting. For the normal case of `RS =
"\n"', the locale is largely irrelevant. For other single-character
@@ -8770,10 +8845,11 @@ File: gawk.info, Node: Expressions Summary, Prev: Locales, Up: Expressions
* `awk' provides the usual arithmetic operators (addition,
subtraction, multiplication, division, modulus), and unary plus
and minus. It also provides comparison operators, boolean
- operators, and regexp matching operators. String concatenation is
- accomplished by placing two expressions next to each other; there
- is no explicit operator. The three-operand `?:' operator provides
- an "if-else" test within expressions.
+ operators, array membership testing, and regexp matching
+ operators. String concatenation is accomplished by placing two
+ expressions next to each other; there is no explicit operator.
+ The three-operand `?:' operator provides an "if-else" test within
+ expressions.
* Assignment operators provide convenient shorthands for common
arithmetic operations.
@@ -8781,8 +8857,8 @@ File: gawk.info, Node: Expressions Summary, Prev: Locales, Up: Expressions
* In `awk', a value is considered to be true if it is non-zero _or_
non-null. Otherwise, the value is false.
- * A value's type is set upon each assignment and may change over its
- lifetime. The type determines how it behaves in comparisons
+ * A variable's type is set upon each assignment and may change over
+ its lifetime. The type determines how it behaves in comparisons
(string or numeric).
* Function calls return a value which may be used as part of a larger
@@ -8808,7 +8884,7 @@ File: gawk.info, Node: Patterns and Actions, Next: Arrays, Prev: Expressions,
As you have already seen, each `awk' statement consists of a pattern
with an associated action. This major node describes how you build
patterns and actions, what kinds of things you can do within actions,
-and `awk''s built-in variables.
+and `awk''s predefined variables.
The pattern-action rules and the statements available for use within
actions form the core of `awk' programming. In a sense, everything
@@ -8822,7 +8898,7 @@ top of. Now it's time to start building something useful.
* Action Overview:: What goes into an action.
* Statements:: Describes the various control statements in
detail.
-* Built-in Variables:: Summarizes the built-in variables.
+* Built-in Variables:: Summarizes the predefined variables.
* Pattern Action Summary:: Patterns and Actions summary.

@@ -8853,7 +8929,7 @@ summary of the types of `awk' patterns:
number) or non-null (if a string). (*Note Expression Patterns::.)
`BEGPAT, ENDPAT'
- A pair of patterns separated by a comma, specifying a range of
+ A pair of patterns separated by a comma, specifying a "range" of
records. The range includes both the initial record that matches
BEGPAT and the final record that matches ENDPAT. (*Note Ranges::.)
@@ -8914,7 +8990,7 @@ precisely `li':
`li'.) Contrast this with the following regular expression match, which
accepts any record with a first field that contains `li':
- $ awk '$1 ~ /foo/ { print $2 }' mail-list
+ $ awk '$1 ~ /li/ { print $2 }' mail-list
-| 555-5553
-| 555-6699
@@ -9064,7 +9140,7 @@ input is read. For example:
$ awk '
> BEGIN { print "Analysis of \"li\"" }
- > /li/ { ++n }
+ > /li/ { ++n }
> END { print "\"li\" appears in", n, "records." }' mail-list
-| Analysis of "li"
-| "li" appears in 4 records.
@@ -9133,9 +9209,10 @@ and `NF' were _undefined_ inside an `END' rule. The POSIX standard
specifies that `NF' is available in an `END' rule. It contains the
number of fields from the last input record. Most probably due to an
oversight, the standard does not say that `$0' is also preserved,
-although logically one would think that it should be. In fact, `gawk'
-does preserve the value of `$0' for use in `END' rules. Be aware,
-however, that BWK `awk', and possibly other implementations, do not.
+although logically one would think that it should be. In fact, all of
+BWK `awk', `mawk', and `gawk' preserve the value of `$0' for use in
+`END' rules. Be aware, however, that some other implementations and
+many older versions of Unix `awk' do not.
The third point follows from the first two. The meaning of `print'
inside a `BEGIN' or `END' rule is the same as always: `print $0'. If
@@ -9204,9 +9281,9 @@ makes it possible to catch and process I/O errors at the level of the
`awk' program.
The `next' statement (*note Next Statement::) is not allowed inside
-either a `BEGINFILE' or and `ENDFILE' rule. The `nextfile' statement
-(*note Nextfile Statement::) is allowed only inside a `BEGINFILE' rule,
-but not inside an `ENDFILE' rule.
+either a `BEGINFILE' or an `ENDFILE' rule. The `nextfile' statement is
+allowed only inside a `BEGINFILE' rule, but not inside an `ENDFILE'
+rule.
The `getline' statement (*note Getline::) is restricted inside both
`BEGINFILE' and `ENDFILE': only redirected forms of `getline' are
@@ -9241,9 +9318,9 @@ hold a pattern that the `awk' program searches for. There are two ways
to get the value of the shell variable into the body of the `awk'
program.
- The most common method is to use shell quoting to substitute the
-variable's value into the program inside the script. For example,
-consider the following program:
+ A common method is to use shell quoting to substitute the variable's
+value into the program inside the script. For example, consider the
+following program:
printf "Enter search pattern: "
read pattern
@@ -9434,18 +9511,18 @@ thing the `while' statement does is test the CONDITION. If the
CONDITION is true, it executes the statement BODY. (The CONDITION is
true when the value is not zero and not a null string.) After BODY has
been executed, CONDITION is tested again, and if it is still true, BODY
-is executed again. This process repeats until the CONDITION is no
-longer true. If the CONDITION is initially false, the body of the loop
-is never executed and `awk' continues with the statement following the
-loop. This example prints the first three fields of each record, one
-per line:
-
- awk '{
- i = 1
- while (i <= 3) {
- print $i
- i++
- }
+executes again. This process repeats until the CONDITION is no longer
+true. If the CONDITION is initially false, the body of the loop never
+executes and `awk' continues with the statement following the loop.
+This example prints the first three fields of each record, one per line:
+
+ awk '
+ {
+ i = 1
+ while (i <= 3) {
+ print $i
+ i++
+ }
}' inventory-shipped
The body of this loop is a compound statement enclosed in braces,
@@ -9476,22 +9553,22 @@ the CONDITION is true. It looks like this:
BODY
while (CONDITION)
- Even if the CONDITION is false at the start, the BODY is executed at
+ Even if the CONDITION is false at the start, the BODY executes at
least once (and only once, unless executing BODY makes CONDITION true).
Contrast this with the corresponding `while' statement:
while (CONDITION)
- BODY
+ BODY
This statement does not execute BODY even once if the CONDITION is
false to begin with. The following is an example of a `do' statement:
{
- i = 1
- do {
- print $0
- i++
- } while (i <= 10)
+ i = 1
+ do {
+ print $0
+ i++
+ } while (i <= 10)
}
This program prints each input record 10 times. However, it isn't a
@@ -9520,9 +9597,10 @@ INCREMENT. Typically, INITIALIZATION sets a variable to either zero or
one, INCREMENT adds one to it, and CONDITION compares it against the
desired number of iterations. For example:
- awk '{
- for (i = 1; i <= 3; i++)
- print $i
+ awk '
+ {
+ for (i = 1; i <= 3; i++)
+ print $i
}' inventory-shipped
This prints the first three fields of each input record, with one field
@@ -9546,7 +9624,7 @@ whatsoever. For example, the following statement prints all the powers
of two between 1 and 100:
for (i = 1; i <= 100; i *= 2)
- print i
+ print i
If there is nothing to be done, any of the three expressions in the
parentheses following the `for' keyword may be omitted. Thus,
@@ -9787,9 +9865,8 @@ complicating the rest of the program, write a "weed out" rule near the
beginning, in the following manner:
NF != 4 {
- err = sprintf("%s:%d: skipped: NF != 4\n", FILENAME, FNR)
- print err > "/dev/stderr"
- next
+ printf("%s:%d: skipped: NF != 4\n", FILENAME, FNR) > "/dev/stderr"
+ next
}
Because of the `next' statement, the program's subsequent rules won't
@@ -9805,11 +9882,11 @@ rules. *Note BEGINFILE/ENDFILE::.
According to the POSIX standard, the behavior is undefined if the
`next' statement is used in a `BEGIN' or `END' rule. `gawk' treats it
-as a syntax error. Although POSIX permits it, most other `awk'
-implementations don't allow the `next' statement inside function bodies
-(*note User-defined::). Just as with any other `next' statement, a
-`next' statement inside a function body reads the next record and
-starts processing it with the first rule in the program.
+as a syntax error. Although POSIX does not disallow it, most other
+`awk' implementations don't allow the `next' statement inside function
+bodies (*note User-defined::). Just as with any other `next'
+statement, a `next' statement inside a function body reads the next
+record and starts processing it with the first rule in the program.

File: gawk.info, Node: Nextfile Statement, Next: Exit Statement, Prev: Next Statement, Up: Statements
@@ -9827,7 +9904,7 @@ reset to one, and processing starts over with the first rule in the
program. If the `nextfile' statement causes the end of the input to be
reached, then the code in any `END' rules is executed. An exception to
this is when `nextfile' is invoked during execution of any statement in
-an `END' rule; In this case, it causes the program to stop immediately.
+an `END' rule; in this case, it causes the program to stop immediately.
*Note BEGIN/END::.
The `nextfile' statement is useful when there are many data files to
@@ -9837,10 +9914,10 @@ would have to continue scanning the unwanted records. The `nextfile'
statement accomplishes this much more efficiently.
In `gawk', execution of `nextfile' causes additional things to
-happen: any `ENDFILE' rules are executed except in the case as
-mentioned below, `ARGIND' is incremented, and any `BEGINFILE' rules are
-executed. (`ARGIND' hasn't been introduced yet. *Note Built-in
-Variables::.)
+happen: any `ENDFILE' rules are executed if `gawk' is not currently in
+an `END' or `BEGINFILE' rule, `ARGIND' is incremented, and any
+`BEGINFILE' rules are executed. (`ARGIND' hasn't been introduced yet.
+*Note Built-in Variables::.)
With `gawk', `nextfile' is useful inside a `BEGINFILE' rule to skip
over a file that would otherwise cause `gawk' to exit with a fatal
@@ -9853,17 +9930,17 @@ files, pipes, and coprocesses that are opened with redirections. It is
not related to the main processing that `awk' does with the files
listed in `ARGV'.
- NOTE: For many years, `nextfile' was a `gawk' extension. As of
+ NOTE: For many years, `nextfile' was a common extension. In
September, 2012, it was accepted for inclusion into the POSIX
standard. See the Austin Group website
(http://austingroupbugs.net/view.php?id=607).
- The current version of BWK `awk', and `mawk' (*note Other
-Versions::) also support `nextfile'. However, they don't allow the
-`nextfile' statement inside function bodies (*note User-defined::).
-`gawk' does; a `nextfile' inside a function body reads the next record
-and starts processing it with the first rule in the program, just as
-any other `nextfile' statement.
+ The current version of BWK `awk', and `mawk' also support
+`nextfile'. However, they don't allow the `nextfile' statement inside
+function bodies (*note User-defined::). `gawk' does; a `nextfile'
+inside a function body reads the next record and starts processing it
+with the first rule in the program, just as any other `nextfile'
+statement.

File: gawk.info, Node: Exit Statement, Prev: Nextfile Statement, Up: Statements
@@ -9887,8 +9964,8 @@ stop immediately.
An `exit' statement that is not part of a `BEGIN' or `END' rule
stops the execution of any further automatic rules for the current
record, skips reading any remaining input records, and executes the
-`END' rule if there is one. Any `ENDFILE' rules are also skipped; they
-are not executed.
+`END' rule if there is one. `gawk' also skips any `ENDFILE' rules;
+they do not execute.
In such a case, if you don't want the `END' rule to do its job, set
a variable to nonzero before the `exit' statement and check that
@@ -9925,8 +10002,8 @@ statement with a nonzero argument, as shown in the following example:

File: gawk.info, Node: Built-in Variables, Next: Pattern Action Summary, Prev: Statements, Up: Patterns and Actions
-7.5 Built-in Variables
-======================
+7.5 Predefined Variables
+========================
Most `awk' variables are available to use for your own purposes; they
never change unless your program assigns values to them, and they never
@@ -9936,7 +10013,7 @@ of these automatically, so that they enable you to tell `awk' how to do
certain things. Others are set automatically by `awk', so that they
carry information from the internal workings of `awk' to your program.
- This minor node documents all of `gawk''s built-in variables, most
+ This minor node documents all of `gawk''s predefined variables, most
of which are also documented in the major nodes describing their areas
of activity.
@@ -9975,7 +10052,7 @@ description of each variable.)
use binary I/O. Any other string value is treated the same as
`"rw"', but causes `gawk' to generate a warning message.
`BINMODE' is described in more detail in *note PC Using::. `mawk'
- *note Other Versions::), also supports this variable, but only
+ (*note Other Versions::), also supports this variable, but only
using numeric values.
``CONVFMT''
@@ -10058,9 +10135,8 @@ description of each variable.)
printing with the `print' statement. It works by being passed as
the first argument to the `sprintf()' function (*note String
Functions::). Its default value is `"%.6g"'. Earlier versions of
- `awk' also used `OFMT' to specify the format for converting
- numbers to strings in general expressions; this is now done by
- `CONVFMT'.
+ `awk' used `OFMT' to specify the format for converting numbers to
+ strings in general expressions; this is now done by `CONVFMT'.
`OFS'
This is the output field separator (*note Output Separators::).
@@ -10169,8 +10245,8 @@ Options::), they are not special.
the command line.
While you can change the value of `ARGIND' within your `awk'
- program, `gawk' automatically sets it to a new value when the next
- file is opened.
+ program, `gawk' automatically sets it to a new value when it opens
+ the next file.
`ENVIRON'
An associative array containing the values of the environment.
@@ -10220,9 +10296,9 @@ Options::), they are not special.
Getline::) inside a `BEGIN' rule can give `FILENAME' a value.
`FNR'
- The current record number in the current file. `FNR' is
- incremented each time a new record is read (*note Records::). It
- is reinitialized to zero each time a new input file is started.
+ The current record number in the current file. `awk' increments
+ `FNR' each time it reads a new record (*note Records::). `awk'
+ resets `FNR' to zero each time it starts a new input file.
`NF'
The number of fields in the current input record. `NF' is set
@@ -10237,7 +10313,8 @@ Options::), they are not special.
`FUNCTAB #'
An array whose indices and corresponding values are the names of
- all the user-defined or extension functions in the program.
+ all the built-in, user-defined and extension functions in the
+ program.
NOTE: Attempting to use the `delete' statement with the
`FUNCTAB' array causes a fatal error. Any attempt to assign
@@ -10245,8 +10322,8 @@ Options::), they are not special.
`NR'
The number of input records `awk' has processed since the
- beginning of the program's execution (*note Records::). `NR' is
- incremented each time a new record is read.
+ beginning of the program's execution (*note Records::). `awk'
+ increments `NR' each time it reads a new record.
`PROCINFO #'
The elements of this array provide access to information about the
@@ -10267,15 +10344,21 @@ Options::), they are not special.
`PROCINFO["identifiers"]'
A subarray, indexed by the names of all identifiers used in
- the text of the AWK program. For each identifier, the value
- of the element is one of the following:
+ the text of the AWK program. An "identifier" is simply the
+ name of a variable (be it scalar or array), built-in
+ function, user-defined function, or extension function. For
+ each identifier, the value of the element is one of the
+ following:
`"array"'
The identifier is an array.
+ `"builtin"'
+ The identifier is a built-in function.
+
`"extension"'
The identifier is an extension function loaded via
- `@load'.
+ `@load' or `-l'.
`"scalar"'
The identifier is a scalar.
@@ -10305,7 +10388,7 @@ Options::), they are not special.
`PROCINFO["sorted_in"]'
If this element exists in `PROCINFO', its value controls the
- order in which array indices will be processed by `for (INDEX
+ order in which array indices will be processed by `for (INDX
in ARRAY)' loops. Since this is an advanced feature, we
defer the full description until later; see *note Scanning an
Array::.
@@ -10323,7 +10406,7 @@ Options::), they are not special.
The following additional elements in the array are available to
provide information about the MPFR and GMP libraries if your
- version of `gawk' supports arbitrary precision numbers (*note
+ version of `gawk' supports arbitrary precision arithmetic (*note
Arbitrary Precision Arithmetic::):
`PROCINFO["mpfr_version"]'
@@ -10356,14 +10439,14 @@ Options::), they are not special.
The `PROCINFO' array has the following additional uses:
- * It may be used to cause coprocesses to communicate over
- pseudo-ttys instead of through two-way pipes; this is
- discussed further in *note Two-way I/O::.
-
* It may be used to provide a timeout when reading from any
open input file, pipe, or coprocess. *Note Read Timeout::,
for more information.
+ * It may be used to cause coprocesses to communicate over
+ pseudo-ttys instead of through two-way pipes; this is
+ discussed further in *note Two-way I/O::.
+
`RLENGTH'
The length of the substring matched by the `match()' function
(*note String Functions::). `RLENGTH' is set by invoking the
@@ -10382,9 +10465,14 @@ Options::), they are not special.
separator. It is set every time a record is read.
`SYMTAB #'
- An array whose indices are the names of all currently defined
- global variables and arrays in the program. The array may be used
- for indirect access to read or write the value of a variable:
+ An array whose indices are the names of all defined global
+ variables and arrays in the program. `SYMTAB' makes `gawk''s
+ symbol table visible to the `awk' programmer. It is built as
+ `gawk' parses the program and is complete before the program
+ starts to run.
+
+ The array may be used for indirect access to read or write the
+ value of a variable:
foo = 5
SYMTAB["foo"] = 4
@@ -10552,6 +10640,12 @@ Because `-q' is not a valid `gawk' option, it and the following `-v'
are passed on to the `awk' program. (*Note Getopt Function::, for an
`awk' library function that parses command-line options.)
+ When designing your program, you should choose options that don't
+conflict with `gawk''s, since it will process any options that it
+accepts before passing the rest of the command line on to your program.
+Using `#!' with the `-E' option may help (*note Executable Scripts::,
+and *note Options::).
+

File: gawk.info, Node: Pattern Action Summary, Prev: Built-in Variables, Up: Patterns and Actions
@@ -10581,8 +10675,8 @@ File: gawk.info, Node: Pattern Action Summary, Prev: Built-in Variables, Up:
* The control statements in `awk' are `if'-`else', `while', `for',
and `do'-`while'. `gawk' adds the `switch' statement. There are
- two flavors of `for' statement: one for for performing general
- looping, and the other iterating through an array.
+ two flavors of `for' statement: one for performing general
+ looping, and the other for iterating through an array.
* `break' and `continue' let you exit early or start the next
iteration of a loop (or get out of a `switch').
@@ -10594,11 +10688,16 @@ File: gawk.info, Node: Pattern Action Summary, Prev: Built-in Variables, Up:
* The `exit' statement terminates your program. When executed from
an action (or function body) it transfers control to the `END'
statements. From an `END' statement body, it exits immediately.
- You may pass an optional numeric value to be used at `awk''s exit
+ You may pass an optional numeric value to be used as `awk''s exit
status.
- * Some built-in variables provide control over `awk', mainly for I/O.
- Other variables convey information from `awk' to your program.
+ * Some predefined variables provide control over `awk', mainly for
+ I/O. Other variables convey information from `awk' to your
+ program.
+
+ * `ARGC' and `ARGV' make the command-line arguments available to
+ your program. Manipulating them from a `BEGIN' rule lets you
+ control how `awk' will process the provided data files.

@@ -10619,26 +10718,21 @@ about array usage. The major node moves on to discuss `gawk''s facility
for sorting arrays, and ends with a brief description of `gawk''s
ability to support true arrays of arrays.
- `awk' maintains a single set of names that may be used for naming
-variables, arrays, and functions (*note User-defined::). Thus, you
-cannot have a variable and an array with the same name in the same
-`awk' program.
-
* Menu:
* Array Basics:: The basics of arrays.
-* Delete:: The `delete' statement removes an element
- from an array.
* Numeric Array Subscripts:: How to use numbers as subscripts in
`awk'.
* Uninitialized Subscripts:: Using Uninitialized variables as subscripts.
+* Delete:: The `delete' statement removes an element
+ from an array.
* Multidimensional:: Emulating multidimensional arrays in
`awk'.
* Arrays of Arrays:: True multidimensional arrays.
* Arrays Summary:: Summary of arrays.

-File: gawk.info, Node: Array Basics, Next: Delete, Up: Arrays
+File: gawk.info, Node: Array Basics, Next: Numeric Array Subscripts, Up: Arrays
8.1 The Basics of Arrays
========================
@@ -10677,8 +10771,8 @@ program.
Arrays in `awk' superficially resemble arrays in other programming
languages, but there are fundamental differences. In `awk', it isn't
necessary to specify the size of an array before starting to use it.
-Additionally, any number or string in `awk', not just consecutive
-integers, may be used as an array index.
+Additionally, any number or string, not just consecutive integers, may
+be used as an array index.
In most other languages, arrays must be "declared" before use,
including a specification of how many elements or components they
@@ -10717,7 +10811,8 @@ array element value:
Index 0 Value 8
Index 2 Value ""
-The pairs are shown in jumbled order because their order is irrelevant.
+The pairs are shown in jumbled order because their order is
+irrelevant.(1)
One advantage of associative arrays is that new pairs can be added
at any time. For example, suppose a tenth element is added to the array
@@ -10746,9 +10841,10 @@ from English to French:
Here we decided to translate the number one in both spelled-out and
numeric form--thus illustrating that a single array can have both
numbers and strings as indices. (In fact, array subscripts are always
-strings; this is discussed in more detail in *note Numeric Array
-Subscripts::.) Here, the number `1' isn't double-quoted, since `awk'
-automatically converts it to a string.
+strings. There are some subtleties to how numbers work when used as
+array subscripts; this is discussed in more detail in *note Numeric
+Array Subscripts::.) Here, the number `1' isn't double-quoted, since
+`awk' automatically converts it to a string.
The value of `IGNORECASE' has no effect upon array subscripting.
The identical string value used to store an array element must be used
@@ -10759,6 +10855,11 @@ starting at one. (*Note String Functions::.)
`awk''s arrays are efficient--the time to access an element is
independent of the number of elements in the array.
+ ---------- Footnotes ----------
+
+ (1) The ordering will vary among `awk' implementations, which
+typically use hash tables to store array elements and values.
+

File: gawk.info, Node: Reference to Elements, Next: Assigning Elements, Prev: Array Intro, Up: Array Basics
@@ -10805,7 +10906,8 @@ index, use the following expression:
This expression tests whether the particular index INDX exists, without
the side effect of creating that element if it is not present. The
expression has the value one (true) if `ARRAY[INDX]' exists and zero
-(false) if it does not exist. For example, this statement tests
+(false) if it does not exist. (We use INDX here, since `index' is the
+name of a built-in function.) For example, this statement tests
whether the array `frequencies' contains the index `2':
if (2 in frequencies)
@@ -10849,14 +10951,14 @@ encountering repeated numbers, gaps, or lines that don't begin with a
number:
{
- if ($1 > max)
- max = $1
- arr[$1] = $0
+ if ($1 > max)
+ max = $1
+ arr[$1] = $0
}
END {
- for (x = 1; x <= max; x++)
- print arr[x]
+ for (x = 1; x <= max; x++)
+ print arr[x]
}
The first rule keeps track of the largest line number seen so far;
@@ -10884,9 +10986,9 @@ overrides the others. Gaps in the line numbers can be handled with an
easy improvement to the program's `END' rule, as follows:
END {
- for (x = 1; x <= max; x++)
- if (x in arr)
- print arr[x]
+ for (x = 1; x <= max; x++)
+ if (x in arr)
+ print arr[x]
}

@@ -10904,7 +11006,7 @@ lowest index up to the highest. This technique won't do the job in
has a special kind of `for' statement for scanning an array:
for (VAR in ARRAY)
- BODY
+ BODY
This loop executes BODY once for each index in ARRAY that the program
has previously used, with the variable VAR set to that index.
@@ -10961,7 +11063,7 @@ all `awk' versions do so. Consider this program, named `loopcheck.awk':
}
}
- Here is what happens when run with `gawk':
+ Here is what happens when run with `gawk' (and `mawk'):
$ gawk -f loopcheck.awk
-| here
@@ -11064,7 +11166,8 @@ available:
to run. Changing `PROCINFO["sorted_in"]' in the loop body does not
affect the loop. For example:
- $ gawk 'BEGIN {
+ $ gawk '
+ > BEGIN {
> a[4] = 4
> a[3] = 3
> for (i in a)
@@ -11072,7 +11175,8 @@ affect the loop. For example:
> }'
-| 4 4
-| 3 3
- $ gawk 'BEGIN {
+ $ gawk '
+ > BEGIN {
> PROCINFO["sorted_in"] = "@ind_str_asc"
> a[4] = 4
> a[3] = 3
@@ -11124,93 +11228,15 @@ ordering when the numeric values are equal ensures that `gawk' behaves
consistently across different environments.

-File: gawk.info, Node: Delete, Next: Numeric Array Subscripts, Prev: Array Basics, Up: Arrays
-
-8.2 The `delete' Statement
-==========================
-
-To remove an individual element of an array, use the `delete' statement:
-
- delete ARRAY[INDEX-EXPRESSION]
-
- Once an array element has been deleted, any value the element once
-had is no longer available. It is as if the element had never been
-referred to or been given a value. The following is an example of
-deleting elements in an array:
-
- for (i in frequencies)
- delete frequencies[i]
-
-This example removes all the elements from the array `frequencies'.
-Once an element is deleted, a subsequent `for' statement to scan the
-array does not report that element and the `in' operator to check for
-the presence of that element returns zero (i.e., false):
-
- delete foo[4]
- if (4 in foo)
- print "This will never be printed"
-
- It is important to note that deleting an element is _not_ the same
-as assigning it a null value (the empty string, `""'). For example:
-
- foo[4] = ""
- if (4 in foo)
- print "This is printed, even though foo[4] is empty"
-
- It is not an error to delete an element that does not exist.
-However, if `--lint' is provided on the command line (*note Options::),
-`gawk' issues a warning message when an element that is not in the
-array is deleted.
-
- All the elements of an array may be deleted with a single statement
-by leaving off the subscript in the `delete' statement, as follows:
-
- delete ARRAY
-
- Using this version of the `delete' statement is about three times
-more efficient than the equivalent loop that deletes each element one
-at a time.
-
- NOTE: For many years, using `delete' without a subscript was a
- `gawk' extension. As of September, 2012, it was accepted for
- inclusion into the POSIX standard. See the Austin Group website
- (http://austingroupbugs.net/view.php?id=544). This form of the
- `delete' statement is also supported by BWK `awk' and `mawk', as
- well as by a number of other implementations (*note Other
- Versions::).
-
- The following statement provides a portable but nonobvious way to
-clear out an array:(1)
-
- split("", array)
-
- The `split()' function (*note String Functions::) clears out the
-target array first. This call asks it to split apart the null string.
-Because there is no data to split out, the function simply clears the
-array and then returns.
-
- CAUTION: Deleting an array does not change its type; you cannot
- delete an array and then use the array's name as a scalar (i.e., a
- regular variable). For example, the following does not work:
-
- a[1] = 3
- delete a
- a = 3
-
- ---------- Footnotes ----------
-
- (1) Thanks to Michael Brennan for pointing this out.
-
-
-File: gawk.info, Node: Numeric Array Subscripts, Next: Uninitialized Subscripts, Prev: Delete, Up: Arrays
+File: gawk.info, Node: Numeric Array Subscripts, Next: Uninitialized Subscripts, Prev: Array Basics, Up: Arrays
-8.3 Using Numbers to Subscript Arrays
+8.2 Using Numbers to Subscript Arrays
=====================================
An important aspect to remember about arrays is that _array subscripts
are always strings_. When a numeric value is used as a subscript, it
is converted to a string value before being used for subscripting
-(*note Conversion::). This means that the value of the built-in
+(*note Conversion::). This means that the value of the predefined
variable `CONVFMT' can affect how your program accesses elements of an
array. For example:
@@ -11233,9 +11259,9 @@ two significant digits. This test fails, since `"12.15"' is different
from `"12.153"'.
According to the rules for conversions (*note Conversion::), integer
-values are always converted to strings as integers, no matter what the
-value of `CONVFMT' may happen to be. So the usual case of the
-following works:
+values always convert to strings as integers, no matter what the value
+of `CONVFMT' may happen to be. So the usual case of the following
+works:
for (i = 1; i <= maxsub; i++)
do something with array[i]
@@ -11248,14 +11274,14 @@ example, that `array[17]', `array[021]', and `array[0x11]' all refer to
the same element!
As with many things in `awk', the majority of the time things work
-as one would expect them to. But it is useful to have a precise
+as you would expect them to. But it is useful to have a precise
knowledge of the actual rules since they can sometimes have a subtle
effect on your programs.

-File: gawk.info, Node: Uninitialized Subscripts, Next: Multidimensional, Prev: Numeric Array Subscripts, Up: Arrays
+File: gawk.info, Node: Uninitialized Subscripts, Next: Delete, Prev: Numeric Array Subscripts, Up: Arrays
-8.4 Using Uninitialized Variables as Subscripts
+8.3 Using Uninitialized Variables as Subscripts
===============================================
Suppose it's necessary to write a program to print the input data in
@@ -11266,7 +11292,7 @@ might look like this:
> line 2
> line 3' | awk '{ l[lines] = $0; ++lines }
> END {
- > for (i = lines-1; i >= 0; --i)
+ > for (i = lines - 1; i >= 0; i--)
> print l[i]
> }'
-| line 3
@@ -11287,7 +11313,7 @@ following version of the program works correctly:
{ l[lines++] = $0 }
END {
- for (i = lines - 1; i >= 0; --i)
+ for (i = lines - 1; i >= 0; i--)
print l[i]
}
@@ -11301,7 +11327,86 @@ string as a subscript if `--lint' is provided on the command line
(*note Options::).

-File: gawk.info, Node: Multidimensional, Next: Arrays of Arrays, Prev: Uninitialized Subscripts, Up: Arrays
+File: gawk.info, Node: Delete, Next: Multidimensional, Prev: Uninitialized Subscripts, Up: Arrays
+
+8.4 The `delete' Statement
+==========================
+
+To remove an individual element of an array, use the `delete' statement:
+
+ delete ARRAY[INDEX-EXPRESSION]
+
+ Once an array element has been deleted, any value the element once
+had is no longer available. It is as if the element had never been
+referred to or been given a value. The following is an example of
+deleting elements in an array:
+
+ for (i in frequencies)
+ delete frequencies[i]
+
+This example removes all the elements from the array `frequencies'.
+Once an element is deleted, a subsequent `for' statement to scan the
+array does not report that element and the `in' operator to check for
+the presence of that element returns zero (i.e., false):
+
+ delete foo[4]
+ if (4 in foo)
+ print "This will never be printed"
+
+ It is important to note that deleting an element is _not_ the same
+as assigning it a null value (the empty string, `""'). For example:
+
+ foo[4] = ""
+ if (4 in foo)
+ print "This is printed, even though foo[4] is empty"
+
+ It is not an error to delete an element that does not exist.
+However, if `--lint' is provided on the command line (*note Options::),
+`gawk' issues a warning message when an element that is not in the
+array is deleted.
+
+ All the elements of an array may be deleted with a single statement
+by leaving off the subscript in the `delete' statement, as follows:
+
+ delete ARRAY
+
+ Using this version of the `delete' statement is about three times
+more efficient than the equivalent loop that deletes each element one
+at a time.
+
+ This form of the `delete' statement is also supported by BWK `awk'
+and `mawk', as well as by a number of other implementations.
+
+ NOTE: For many years, using `delete' without a subscript was a
+ common extension. In September, 2012, it was accepted for
+ inclusion into the POSIX standard. See the Austin Group website
+ (http://austingroupbugs.net/view.php?id=544).
+
+ The following statement provides a portable but nonobvious way to
+clear out an array:(1)
+
+ split("", array)
+
+ The `split()' function (*note String Functions::) clears out the
+target array first. This call asks it to split apart the null string.
+Because there is no data to split out, the function simply clears the
+array and then returns.
+
+ CAUTION: Deleting all the elements from an array does not change
+ its type; you cannot clear an array and then use the array's name
+ as a scalar (i.e., a regular variable). For example, the following
+ does not work:
+
+ a[1] = 3
+ delete a
+ a = 3
+
+ ---------- Footnotes ----------
+
+ (1) Thanks to Michael Brennan for pointing this out.
+
+
+File: gawk.info, Node: Multidimensional, Next: Arrays of Arrays, Prev: Delete, Up: Arrays
8.5 Multidimensional Arrays
===========================
@@ -11313,7 +11418,7 @@ File: gawk.info, Node: Multidimensional, Next: Arrays of Arrays, Prev: Uninit
A multidimensional array is an array in which an element is
identified by a sequence of indices instead of a single index. For
example, a two-dimensional array requires two indices. The usual way
-(in most languages, including `awk') to refer to an element of a
+(in many languages, including `awk') to refer to an element of a
two-dimensional array named `grid' is with `grid[X,Y]'.
Multidimensional arrays are supported in `awk' through concatenation
@@ -11454,8 +11559,9 @@ multidimensional subscript). So the following is valid in `gawk':
Each subarray and the main array can be of different length. In
fact, the elements of an array or its subarray do not all have to have
the same type. This means that the main array and any of its subarrays
-can be non-rectangular, or jagged in structure. One can assign a scalar
-value to the index `4' of the main array `a':
+can be non-rectangular, or jagged in structure. You can assign a scalar
+value to the index `4' of the main array `a', even though `a[1]' is
+itself an array and not a scalar:
a[4] = "An element in a jagged array"
@@ -11516,6 +11622,8 @@ an array element is itself an array:
print array[i][j]
}
}
+ else
+ print array[i]
}
If the structure of a jagged array of arrays is known in advance,
@@ -11746,8 +11854,9 @@ brackets ([ ]):
user-defined function that can be used to obtain a random
non-negative integer less than N:
- function randint(n) {
- return int(n * rand())
+ function randint(n)
+ {
+ return int(n * rand())
}
The multiplication produces a random number greater than zero and
@@ -11764,8 +11873,7 @@ brackets ([ ]):
# Roll 3 six-sided dice and
# print total number of points.
{
- printf("%d points\n",
- roll(6)+roll(6)+roll(6))
+ printf("%d points\n", roll(6) + roll(6) + roll(6))
}
CAUTION: In most `awk' implementations, including `gawk',
@@ -11852,8 +11960,7 @@ with character indices, and not byte indices.
In the following list, optional parameters are enclosed in square
brackets ([ ]). Several functions perform string substitution; the
full discussion is provided in the description of the `sub()' function,
-which comes towards the end since the list is presented in alphabetic
-order.
+which comes towards the end since the list is presented alphabetically.
Those functions that are specific to `gawk' are marked with a pound
sign (`#'). They are not available in compatibility mode (*note
@@ -11886,7 +11993,8 @@ Options::):
When comparing strings, `IGNORECASE' affects the sorting (*note
Array Sorting Functions::). If the SOURCE array contains
subarrays as values (*note Arrays of Arrays::), they will come
- last, after all scalar values.
+ last, after all scalar values. Subarrays are _not_ recursively
+ sorted.
For example, if the contents of `a' are as follows:
@@ -11989,7 +12097,10 @@ Options::):
If FIND is not found, `index()' returns zero.
- It is a fatal error to use a regexp constant for FIND.
+ With BWK `awk' and `gawk', it is a fatal error to use a regexp
+ constant for FIND. Other implementations allow it, simply
+ treating the regexp constant as an expression meaning `$0 ~
+ /regexp/'. (d.c.).
`length('[STRING]`)'
Return the number of characters in STRING. If STRING is a number,
@@ -12049,21 +12160,20 @@ Options::):
`match()', the order is the same as for the `~' operator: `STRING
~ REGEXP'.
- The `match()' function sets the built-in variable `RSTART' to the
- index. It also sets the built-in variable `RLENGTH' to the length
- in characters of the matched substring. If no match is found,
- `RSTART' is set to zero, and `RLENGTH' to -1.
+ The `match()' function sets the predefined variable `RSTART' to
+ the index. It also sets the predefined variable `RLENGTH' to the
+ length in characters of the matched substring. If no match is
+ found, `RSTART' is set to zero, and `RLENGTH' to -1.
For example:
{
- if ($1 == "FIND")
- regex = $2
- else {
- where = match($0, regex)
- if (where != 0)
- print "Match of", regex, "found at",
- where, "in", $0
+ if ($1 == "FIND")
+ regex = $2
+ else {
+ where = match($0, regex)
+ if (where != 0)
+ print "Match of", regex, "found at", where, "in", $0
}
}
@@ -12132,7 +12242,7 @@ Options::):
The `patsplit()' function splits strings into pieces in a manner
similar to the way input lines are split into fields using `FPAT'
- (*note Splitting By Content::.
+ (*note Splitting By Content::).
Before splitting the string, `patsplit()' deletes any previously
existing elements in the arrays ARRAY and SEPS.
@@ -12143,15 +12253,14 @@ Options::):
first piece is stored in `ARRAY[1]', the second piece in
`ARRAY[2]', and so forth. The string value of the third argument,
FIELDSEP, is a regexp describing where to split STRING (much as
- `FS' can be a regexp describing where to split input records;
- *note Regexp Field Splitting::). If FIELDSEP is omitted, the
- value of `FS' is used. `split()' returns the number of elements
- created. SEPS is a `gawk' extension with `SEPS[I]' being the
- separator string between `ARRAY[I]' and `ARRAY[I+1]'. If FIELDSEP
- is a single space then any leading whitespace goes into `SEPS[0]'
- and any trailing whitespace goes into `SEPS[N]' where N is the
- return value of `split()' (that is, the number of elements in
- ARRAY).
+ `FS' can be a regexp describing where to split input records). If
+ FIELDSEP is omitted, the value of `FS' is used. `split()' returns
+ the number of elements created. SEPS is a `gawk' extension with
+ `SEPS[I]' being the separator string between `ARRAY[I]' and
+ `ARRAY[I+1]'. If FIELDSEP is a single space then any leading
+ whitespace goes into `SEPS[0]' and any trailing whitespace goes
+ into `SEPS[N]' where N is the return value of `split()' (that is,
+ the number of elements in ARRAY).
The `split()' function splits strings into pieces in a manner
similar to the way input lines are split into fields. For example:
@@ -12357,6 +12466,17 @@ Options::):
Nonalphabetic characters are left unchanged. For example,
`toupper("MiXeD cAsE 123")' returns `"MIXED CASE 123"'.
+ Matching the Null String
+
+ In `awk', the `*' operator can match the null string. This is
+particularly important for the `sub()', `gsub()', and `gensub()'
+functions. For example:
+
+ $ echo abc | awk '{ gsub(/m*/, "X"); print }'
+ -| XaXbXcX
+
+Although this makes a certain amount of sense, it can be surprising.
+
---------- Footnotes ----------
(1) Unless you use the `--non-decimal-data' option, which isn't
@@ -12376,8 +12496,8 @@ File: gawk.info, Node: Gory Details, Up: String Functions
9.1.3.1 More About `\' and `&' with `sub()', `gsub()', and `gensub()'
.....................................................................
- CAUTION: This section has been known to cause headaches. You
- might want to skip it upon first reading.
+ CAUTION: This subsubsection has been reported to cause headaches.
+ You might want to skip it upon first reading.
When using `sub()', `gsub()', or `gensub()', and trying to get
literal backslashes and ampersands into the replacement text, you need
@@ -12511,17 +12631,6 @@ Table 9.4: Escape Sequence Processing For `gensub()'
and the special cases for `sub()' and `gsub()', we recommend the use of
`gawk' and `gensub()' when you have to do substitutions.
- Matching the Null String
-
- In `awk', the `*' operator can match the null string. This is
-particularly important for the `sub()', `gsub()', and `gensub()'
-functions. For example:
-
- $ echo abc | awk '{ gsub(/m*/, "X"); print }'
- -| XaXbXcX
-
-Although this makes a certain amount of sense, it can be surprising.
-
---------- Footnotes ----------
(1) This was rather naive of him, despite there being a note in this
@@ -12571,11 +12680,10 @@ parameters are enclosed in square brackets ([ ]):
function--`gawk' also buffers its output and the `fflush()'
function forces `gawk' to flush its buffers.
- `fflush()' was added to BWK `awk' in April of 1992. For two
- decades, it was not part of the POSIX standard. As of December,
- 2012, it was accepted for inclusion into the POSIX standard. See
- the Austin Group website
- (http://austingroupbugs.net/view.php?id=634).
+ Brian Kernighan added `fflush()' to his `awk' in April of 1992.
+ For two decades, it was a common extension. In December, 2012, it
+ was accepted for inclusion into the POSIX standard. See the
+ Austin Group website (http://austingroupbugs.net/view.php?id=634).
POSIX standardizes `fflush()' as follows: If there is no argument,
or if the argument is the null string (`""'), then `awk' flushes
@@ -12762,7 +12870,7 @@ enclosed in square brackets ([ ]):
If DATESPEC does not contain enough elements or if the resulting
time is out of range, `mktime()' returns -1.
-`strftime(' [FORMAT [`,' TIMESTAMP [`,' UTC-FLAG] ] ]`)'
+`strftime('[FORMAT [`,' TIMESTAMP [`,' UTC-FLAG] ] ]`)'
Format the time specified by TIMESTAMP based on the contents of
the FORMAT string and return the result. It is similar to the
function of the same name in ISO C. If UTC-FLAG is present and is
@@ -12977,7 +13085,7 @@ to the standard output and interprets the current time according to the
format specifiers in the string. For example:
$ date '+Today is %A, %B %d, %Y.'
- -| Today is Monday, May 05, 2014.
+ -| Today is Monday, September 22, 2014.
Here is the `gawk' version of the `date' utility. It has a shell
"wrapper" to handle the `-u' option, which requires that `date' run as
@@ -13066,12 +13174,13 @@ a given value.
Finally, two other common operations are to shift the bits left or
right. For example, if you have a bit string `10111001' and you shift
-it right by three bits, you end up with `00010111'.(1) If you start over
-again with `10111001' and shift it left by three bits, you end up with
-`11001000'. `gawk' provides built-in functions that implement the
-bitwise operations just described. They are:
+it right by three bits, you end up with `00010111'.(1) If you start
+over again with `10111001' and shift it left by three bits, you end up
+with `11001000'. The following list describes `gawk''s built-in
+functions that implement the bitwise operations. Optional parameters
+are enclosed in square brackets ([ ]):
-``and(V1, V2' [`,' ...]`)''
+``and('V1`,' V2 [`,' ...]`)''
Return the bitwise AND of the arguments. There must be at least
two.
@@ -13081,13 +13190,13 @@ bitwise operations just described. They are:
``lshift(VAL, COUNT)''
Return the value of VAL, shifted left by COUNT bits.
-``or(V1, V2' [`,' ...]`)''
+``or('V1`,' V2 [`,' ...]`)''
Return the bitwise OR of the arguments. There must be at least two.
``rshift(VAL, COUNT)''
Return the value of VAL, shifted right by COUNT bits.
-``xor(V1, V2' [`,' ...]`)''
+``xor('V1`,' V2 [`,' ...]`)''
Return the bitwise XOR of the arguments. There must be at least
two.
@@ -13162,7 +13271,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
@@ -13172,7 +13281,7 @@ File: gawk.info, Node: Type Functions, Next: I18N Functions, Prev: Bitwise Fu
`gawk' provides a single function that lets you distinguish an array
from a scalar variable. This is necessary for writing code that
-traverses every element of an array of arrays. (*note Arrays of
+traverses every element of an array of arrays (*note Arrays of
Arrays::).
`isarray(X)'
@@ -13184,12 +13293,12 @@ itself an array or not. The second is inside the body of a
user-defined function (not discussed yet; *note User-defined::), to
test if a parameter is an array or not.
- Note, however, that using `isarray()' at the global level to test
-variables makes no sense. Since you are the one writing the program, you
-are supposed to know if your variables are arrays or not. And in fact,
-due to the way `gawk' works, if you pass the name of a variable that
-has not been previously used to `isarray()', `gawk' will end up turning
-it into a scalar.
+ NOTE: Using `isarray()' at the global level to test variables
+ makes no sense. Since you are the one writing the program, you are
+ supposed to know if your variables are arrays or not. And in fact,
+ due to the way `gawk' works, if you pass the name of a variable
+ that has not been previously used to `isarray()', `gawk' ends up
+ turning it into a scalar.

File: gawk.info, Node: I18N Functions, Prev: Type Functions, Up: Built-in
@@ -13253,7 +13362,10 @@ File: gawk.info, Node: Definition Syntax, Next: Function Example, Up: User-de
9.2.1 Function Definition Syntax
--------------------------------
-Definitions of functions can appear anywhere between the rules of an
+ It's entirely fair to say that the `awk' syntax for local variable
+ definitions is appallingly awful. -- Brian Kernighan
+
+ Definitions of functions can appear anywhere between the rules of an
`awk' program. Thus, the general form of an `awk' program is extended
to include sequences of rules _and_ user-defined function definitions.
There is no need to put the definition of a function before all uses of
@@ -13269,9 +13381,10 @@ starting to execute any of it.
Here, NAME is the name of the function to define. A valid function
name is like a valid variable name: a sequence of letters, digits, and
-underscores that doesn't start with a digit. Within a single `awk'
-program, any particular name can only be used as a variable, array, or
-function.
+underscores that doesn't start with a digit. Here too, only the 52
+upper- and lowercase English letters may be used in a function name.
+Within a single `awk' program, any particular name can only be used as
+a variable, array, or function.
PARAMETER-LIST is an optional list of the function's arguments and
local variable names, separated by commas. When the function is called,
@@ -13281,9 +13394,9 @@ call.
A function cannot have two parameters with the same name, nor may it
have a parameter with the same name as the function itself. In
addition, according to the POSIX standard, function parameters cannot
-have the same name as one of the special built-in variables (*note
+have the same name as one of the special predefined variables (*note
Built-in Variables::). Not all versions of `awk' enforce this
-restriction.)
+restriction.
Local variables act like the empty string if referenced where a
string value is required, and like zero if referenced where a numeric
@@ -13396,7 +13509,7 @@ extra whitespace signifies the start of the local variable list):
function delarray(a, i)
{
for (i in a)
- delete a[i]
+ delete a[i]
}
When working with arrays, it is often necessary to delete all the
@@ -13404,8 +13517,8 @@ elements in an array and start over with a new list of elements (*note
Delete::). Instead of having to repeat this loop everywhere that you
need to clear out an array, your program can just call `delarray'.
(This guarantees portability. The use of `delete ARRAY' to delete the
-contents of an entire array is a recent(1) addition to the POSIX
-standard.)
+contents of an entire array is a relatively recent(1) addition to the
+POSIX standard.)
The following is an example of a recursive function. It takes a
string as an input parameter and returns the string in backwards order.
@@ -13428,7 +13541,7 @@ way:
> gawk -e '{ print rev($0) }' -f rev.awk
-| !cinaP t'noD
- The C `ctime()' function takes a timestamp and returns it in a
+ The C `ctime()' function takes a timestamp and returns it as a
string, formatted in a well-known fashion. The following example uses
the built-in `strftime()' function (*note Time Functions::) to create
an `awk' version of `ctime()':
@@ -13439,12 +13552,18 @@ an `awk' version of `ctime()':
function ctime(ts, format)
{
- format = PROCINFO["strftime"]
+ format = "%a %b %e %H:%M:%S %Z %Y"
+
if (ts == 0)
ts = systime() # use current time as default
return strftime(format, ts)
}
+ You might think that `ctime()' could use `PROCINFO["strftime"]' for
+its format string. That would be a mistake, since `ctime()' is supposed
+to return the time formatted in a standard fashion, and user-level code
+could have changed `PROCINFO["strftime"]'.
+
---------- Footnotes ----------
(1) Late in 2012.
@@ -13825,7 +13944,7 @@ File: gawk.info, Node: Indirect Calls, Next: Functions Summary, Prev: User-de
9.3 Indirect Function Calls
===========================
-This section describes a `gawk'-specific extension.
+This section describes an advanced, `gawk'-specific extension.
Often, you may wish to defer the choice of function to call until
runtime. For example, you may have different kinds of records, each of
@@ -13864,7 +13983,7 @@ your test scores:
This style of programming works, but can be awkward. With "indirect"
function calls, you tell `gawk' to use the _value_ of a variable as the
-name of the function to call.
+_name_ of the function to call.
The syntax is similar to that of a regular function call: an
identifier immediately followed by a left parenthesis, any arguments,
@@ -13906,7 +14025,6 @@ using indirect function calls.
Otherwise they perform the expected computations and are not unusual.
# For each record, print the class name and the requested statistics
-
{
class_name = $1
gsub(/_/, " ", class_name) # Replace _ with spaces
@@ -13987,7 +14105,7 @@ mechanism allows you to sort arbitrary data in an arbitrary fashion.
# quicksort_swap --- helper function for quicksort, should really be inline
- function quicksort_swap(data, i, j, temp)
+ function quicksort_swap(data, i, j, temp)
{
temp = data[i]
data[i] = data[j]
@@ -14090,14 +14208,71 @@ names of the two comparison functions:
-| sort: <87.1 93.4 95.6 100.0>
-| rsort: <100.0 95.6 93.4 87.1>
+ Another example where indirect functions calls are useful can be
+found in processing arrays. *note Walking Arrays::, presented a simple
+function for "walking" an array of arrays. That function simply
+printed the name and value of each scalar array element. However, it is
+easy to generalize that function, by passing in the name of a function
+to call when walking an array. The modified function looks like this:
+
+ function process_array(arr, name, process, do_arrays, i, new_name)
+ {
+ for (i in arr) {
+ new_name = (name "[" i "]")
+ if (isarray(arr[i])) {
+ if (do_arrays)
+ @process(new_name, arr[i])
+ process_array(arr[i], new_name, process, do_arrays)
+ } else
+ @process(new_name, arr[i])
+ }
+ }
+
+ The arguments are as follows:
+
+`arr'
+ The array.
+
+`name'
+ The name of the array (a string).
+
+`process'
+ The name of the function to call.
+
+`do_arrays'
+ If this is true, the function can handle elements that are
+ subarrays.
+
+ If subarrays are to be processed, that is done before walking them
+further.
+
+ When run with the following scaffolding, the function produces the
+same results as does the earlier `walk_array()' function:
+
+ BEGIN {
+ a[1] = 1
+ a[2][1] = 21
+ a[2][2] = 22
+ a[3] = 3
+ a[4][1][1] = 411
+ a[4][2] = 42
+
+ process_array(a, "a", "do_print", 0)
+ }
+
+ function do_print(name, element)
+ {
+ printf "%s = %s\n", name, element
+ }
+
Remember that you must supply a leading `@' in front of an indirect
function call.
- Unfortunately, indirect function calls cannot be used with the
-built-in functions. However, you can generally write "wrapper"
-functions which call the built-in ones, and those can be called
-indirectly. (Other than, perhaps, the mathematical functions, there is
-not a lot of reason to try to call the built-in functions indirectly.)
+ Starting with version 4.1.2 of `gawk', indirect function calls may
+also be used with built-in functions and with extension functions
+(*note Dynamic Extensions::). The only thing you cannot do is pass a
+regular expression constant to a built-in function through an indirect
+function call.(1)
`gawk' does its best to make indirect function calls efficient. For
example, in the following case:
@@ -14105,7 +14280,12 @@ example, in the following case:
for (i = 1; i <= n; i++)
@the_func()
-`gawk' will look up the actual function to call only once.
+`gawk' looks up the actual function to call only once.
+
+ ---------- Footnotes ----------
+
+ (1) This may change in a future version; recheck the documentation
+that comes with your version of `gawk' to see if it has.

File: gawk.info, Node: Functions Summary, Prev: Indirect Calls, Up: Functions
@@ -14117,11 +14297,12 @@ File: gawk.info, Node: Functions Summary, Prev: Indirect Calls, Up: Functions
functions.
* POSIX `awk' provides three kinds of built-in functions: numeric,
- string, and I/O. `gawk' provides functions that work with values
- representing time, do bit manipulation, sort arrays, and
- internationalize and localize programs. `gawk' also provides
- several extensions to some of standard functions, typically in the
- form of additional arguments.
+ string, and I/O. `gawk' provides functions that sort arrays, work
+ with values representing time, do bit manipulation, determine
+ variable type (array vs. scalar), and internationalize and
+ localize programs. `gawk' also provides several extensions to
+ some of standard functions, typically in the form of additional
+ arguments.
* Functions accept zero or more arguments and return a value. The
expressions that provide the argument values are completely
@@ -14142,7 +14323,9 @@ File: gawk.info, Node: Functions Summary, Prev: Indirect Calls, Up: Functions
* User-defined functions may call other user-defined (and built-in)
functions and may call themselves recursively. Function parameters
- "hide" any global variables of the same names.
+ "hide" any global variables of the same names. You cannot use the
+ name of a reserved variable (such as `ARGC') as the name of a
+ parameter in user-defined functions.
* Scalar values are passed to user-defined functions by value. Array
parameters are passed by reference; any changes made by the
@@ -14158,10 +14341,9 @@ File: gawk.info, Node: Functions Summary, Prev: Indirect Calls, Up: Functions
either scalar or array.
* `gawk' provides indirect function calls using a special syntax.
- By setting a variable to the name of a user-defined function, you
- can determine at runtime what function will be called at that
- point in the program. This is equivalent to function pointers in C
- and C++.
+ By setting a variable to the name of a function, you can determine
+ at runtime what function will be called at that point in the
+ program. This is equivalent to function pointers in C and C++.

@@ -14241,7 +14423,7 @@ for different implementations of `awk' is pretty straightforward.
* Group Functions:: Functions for getting group information.
* Walking Arrays:: A function to walk arrays of arrays.
* Library Functions Summary:: Summary of library functions.
-* Library exercises:: Exercises.
+* Library Exercises:: Exercises.
---------- Footnotes ----------
@@ -14295,7 +14477,7 @@ to start that variable's name with a capital letter--for example,
`getopt()''s `Opterr' and `Optind' variables (*note Getopt Function::).
The leading capital letter indicates that it is global, while the fact
that the variable name is not all capital letters indicates that the
-variable is not one of `awk''s built-in variables, such as `FS'.
+variable is not one of `awk''s predefined variables, such as `FS'.
It is also important that _all_ variables in library functions that
do not need to save state are, in fact, declared local.(2) If this is
@@ -14305,8 +14487,9 @@ program, leading to bugs that are very difficult to track down:
function lib_func(x, y, l1, l2)
{
...
- USE VARIABLE some_var # some_var should be local
- ... # but is not by oversight
+ # some_var should be local but by oversight is not
+ USE VARIABLE some_var
+ ...
}
A different convention, common in the Tcl community, is to use a
@@ -14355,6 +14538,7 @@ programming use.
* Join Function:: A function to join an array into a string.
* Getlocaltime Function:: A function to get formatted times.
* Readfile Function:: A function to read an entire file at once.
+* Shell Quoting:: A function to quote strings for the shell.

File: gawk.info, Node: Strtonum Function, Next: Assert Function, Up: General Functions
@@ -14376,8 +14560,9 @@ versions of `awk':
ret = 0
for (i = 1; i <= n; i++) {
c = substr(str, i, 1)
- if ((k = index("01234567", c)) > 0)
- k-- # adjust for 1-basing in awk
+ # index() returns 0 if c not in string,
+ # includes c == "0"
+ k = index("1234567", c)
ret = ret * 8 + k
}
@@ -14389,6 +14574,8 @@ versions of `awk':
for (i = 1; i <= n; i++) {
c = substr(str, i, 1)
c = tolower(c)
+ # index() returns 0 if c not in string,
+ # includes c == "0"
k = index("123456789abcdef", c)
ret = ret * 16 + k
@@ -14411,7 +14598,7 @@ versions of `awk':
# a[5] = "123.45"
# a[6] = "1.e3"
# a[7] = "1.32"
- # a[7] = "1.32E2"
+ # a[8] = "1.32E2"
#
# for (i = 1; i in a; i++)
# print a[i], strtonum(a[i]), mystrtonum(a[i])
@@ -14420,9 +14607,11 @@ versions of `awk':
The function first looks for C-style octal numbers (base 8). If the
input string matches a regular expression describing octal numbers,
then `mystrtonum()' loops through each character in the string. It
-sets `k' to the index in `"01234567"' of the current octal digit.
-Since the return value is one-based, the `k--' adjusts `k' so it can be
-used in computing the return value.
+sets `k' to the index in `"1234567"' of the current octal digit. The
+return value will either be the same number as the digit, or zero if
+the character is not there, which will be true for a `0'. This is
+safe, since the regexp test in the `if' ensures that only octal values
+are converted.
Similar logic applies to the code that checks for and converts a
hexadecimal value, which starts with `0x' or `0X'. The use of
@@ -14448,7 +14637,7 @@ condition or set of conditions is true. Before proceeding with a
particular computation, you make a statement about what you believe to
be the case. Such a statement is known as an "assertion". The C
language provides an `<assert.h>' header file and corresponding
-`assert()' macro that the programmer can use to make assertions. If an
+`assert()' macro that a programmer can use to make assertions. If an
assertion fails, the `assert()' macro arranges to print a diagnostic
message describing the condition that should have been true but was
not, and then it kills the program. In C, using `assert()' looks this:
@@ -14669,8 +14858,7 @@ worrying about:
}
#### test code ####
- # BEGIN \
- # {
+ # BEGIN {
# for (;;) {
# printf("enter a character: ")
# if (getline var <= 0)
@@ -14789,7 +14977,7 @@ current time formatted in the same way as the `date' utility:
now = systime()
# return date(1)-style output
- ret = strftime(PROCINFO["strftime"], now)
+ ret = strftime("%a %b %e %H:%M:%S %Z %Y", now)
# clear out target array
delete time
@@ -14826,7 +15014,7 @@ the `getlocaltime()' function would have allowed the user to supply an
optional timestamp value to use instead of the current time.

-File: gawk.info, Node: Readfile Function, Prev: Getlocaltime Function, Up: General Functions
+File: gawk.info, Node: Readfile Function, Next: Shell Quoting, Prev: Getlocaltime Function, Up: General Functions
10.2.8 Reading A Whole File At Once
-----------------------------------
@@ -14885,6 +15073,61 @@ string. Thus calling code may use something like:
This tests the result to see if it is empty or not. An equivalent
test would be `contents == ""'.
+ *Note Extension Sample Readfile::, for an extension function that
+also reads an entire file into memory.
+
+
+File: gawk.info, Node: Shell Quoting, Prev: Readfile Function, Up: General Functions
+
+10.2.9 Quoting Strings to Pass to The Shell
+-------------------------------------------
+
+Michael Brennan offers the following programming pattern, which he uses
+frequently:
+
+ #! /bin/sh
+
+ awkp='
+ ...
+ '
+
+ INPUT_PROGRAM | awk "$awkp" | /bin/sh
+
+ For example, a program of his named `flac-edit' has this form:
+
+ $ flac-edit -song="Whoope! That's Great" file.flac
+
+ It generates the following output, which is to be piped to the shell
+(`/bin/sh'):
+
+ chmod +w file.flac
+ metaflac --remove-tag=TITLE file.flac
+ LANG=en_US.88591 metaflac --set-tag=TITLE='Whoope! That'"'"'s Great' file.flac
+ chmod -w file.flac
+
+ Note the need for shell quoting. The function `shell_quote()' does
+it. `SINGLE' is the one-character string `"'"' and `QSINGLE' is the
+three-character string `"\"'\""'.
+
+ # shell_quote --- quote an argument for passing to the shell
+
+ function shell_quote(s, # parameter
+ SINGLE, QSINGLE, i, X, n, ret) # locals
+ {
+ if (s == "")
+ return "\"\""
+
+ SINGLE = "\x27" # single quote
+ QSINGLE = "\"\x27\""
+ n = split(s, X, SINGLE)
+
+ ret = SINGLE X[1] SINGLE
+ for (i = 2; i <= n; i++)
+ ret = ret QSINGLE SINGLE X[i] SINGLE
+
+ return ret
+ }
+

File: gawk.info, Node: Data File Management, Next: Getopt Function, Prev: General Functions, Up: Library Functions
@@ -14934,15 +15177,14 @@ does so _portably_; this works with any implementation of `awk':
# that each take the name of the file being started or
# finished, respectively.
- FILENAME != _oldfilename \
- {
+ FILENAME != _oldfilename {
if (_oldfilename != "")
endfile(_oldfilename)
_oldfilename = FILENAME
beginfile(FILENAME)
}
- END { endfile(FILENAME) }
+ END { endfile(FILENAME) }
This file must be loaded before the user's "main" program, so that
the rule it supplies is executed first.
@@ -14980,7 +15222,7 @@ solves the problem:
beginfile(FILENAME)
}
- END { endfile(_filename_) }
+ END { endfile(_filename_) }
*note Wc Program::, shows how this library function can be used and
how it simplifies writing the main program.
@@ -15033,15 +15275,12 @@ over with it from the top. For lack of a better name, we'll call it
nextfile
}
- This code relies on the `ARGIND' variable (*note Auto-set::), which
-is specific to `gawk'. If you are not using `gawk', you can use ideas
-presented in *note Filetrans Function::, to either update `ARGIND' on
-your own or modify this code as appropriate.
-
- The `rewind()' function also relies on the `nextfile' keyword (*note
-Nextfile Statement::). Because of this, you should not call it from an
-`ENDFILE' rule. (This isn't necessary anyway, since as soon as an
-`ENDFILE' rule finishes `gawk' goes to the next file!)
+ The `rewind()' function relies on the `ARGIND' variable (*note
+Auto-set::), which is specific to `gawk'. It also relies on the
+`nextfile' keyword (*note Nextfile Statement::). Because of this, you
+should not call it from an `ENDFILE' rule. (This isn't necessary
+anyway, since as soon as an `ENDFILE' rule finishes `gawk' goes to the
+next file!)

File: gawk.info, Node: File Checking, Next: Empty Files, Prev: Rewind Function, Up: Data File Management
@@ -15058,7 +15297,7 @@ following program to your `awk' program:
BEGIN {
for (i = 1; i < ARGC; i++) {
- if (ARGV[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/ \
+ if (ARGV[i] ~ /^[a-zA-Z_][a-zA-Z0-9_]*=.*/ \
|| ARGV[i] == "-" || ARGV[i] == "/dev/stdin")
continue # assignment or standard input
else if ((getline junk < ARGV[i]) < 0) # unreadable
@@ -15072,6 +15311,10 @@ following program to your `awk' program:
element from `ARGV' with `delete' skips the file (since it's no longer
in the list). See also *note ARGC and ARGV::.
+ The regular expression check purposely does not use character classes
+such as `[:alpha:]' and `[:alnum:]' (*note Bracket Expressions::) since
+`awk' variable names only allow the English letters.
+
---------- Footnotes ----------
(1) The `BEGINFILE' special pattern (*note BEGINFILE/ENDFILE::)
@@ -15150,7 +15393,7 @@ programming with a library file does the trick:
function disable_assigns(argc, argv, i)
{
for (i = 1; i < argc; i++)
- if (argv[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/)
+ if (argv[i] ~ /^[a-zA-Z_][a-zA-Z0-9_]*=.*/)
argv[i] = ("./" argv[i])
}
@@ -15338,8 +15581,7 @@ not an option, and it ends option processing. Continuing on:
i = index(options, thisopt)
if (i == 0) {
if (Opterr)
- printf("%c -- invalid option\n",
- thisopt) > "/dev/stderr"
+ printf("%c -- invalid option\n", thisopt) > "/dev/stderr"
if (_opti >= length(argv[Optind])) {
Optind++
_opti = 0
@@ -15451,10 +15693,14 @@ result of two sample runs of the test program:
In both runs, the first `--' terminates the arguments to `awk', so
that it does not try to interpret the `-a', etc., as its own options.
- NOTE: After `getopt()' is through, it is the responsibility of the
- user level code to clear out all the elements of `ARGV' from 1 to
- `Optind', so that `awk' does not try to process the command-line
- options as file names.
+ NOTE: After `getopt()' is through, user level code must clear out
+ all the elements of `ARGV' from 1 to `Optind', so that `awk' does
+ not try to process the command-line options as file names.
+
+ Using `#!' with the `-E' option may help avoid conflicts between
+your program's options and `gawk''s options, since `-E' causes `gawk'
+to abandon processing of further options (*note Executable Scripts::,
+and *note Options::).
Several of the sample programs presented in *note Sample Programs::,
use `getopt()' to process their arguments.
@@ -15613,8 +15859,8 @@ corresponding to the C functions of the same names:
routine, we have chosen to put it in `/usr/local/libexec/awk'; however,
you might want it to be in a different directory on your system.
- The function `_pw_init()' keeps three copies of the user information
-in three associative arrays. The arrays are indexed by username
+ The function `_pw_init()' fills three copies of the user information
+into three associative arrays. The arrays are indexed by username
(`_pw_byname'), by user ID number (`_pw_byuid'), and by order of
occurrence (`_pw_bycount'). The variable `_pw_inited' is used for
efficiency, since `_pw_init()' needs to be called only once.
@@ -15624,13 +15870,10 @@ efficiency, since `_pw_init()' needs to be called only once.
in the variable `using_fw' whether field splitting with `FIELDWIDTHS'
is in effect or not. Doing so is necessary, since these functions
could be called from anywhere within a user's program, and the user may
-have his or her own way of splitting records and fields.
-
- The `using_fw' variable checks `PROCINFO["FS"]', which is
-`"FIELDWIDTHS"' if field splitting is being done with `FIELDWIDTHS'.
-This makes it possible to restore the correct field-splitting mechanism
-later. The test can only be true for `gawk'. It is false if using
-`FS' or `FPAT', or on some other `awk' implementation.
+have his or her own way of splitting records and fields. This makes it
+possible to restore the correct field-splitting mechanism later. The
+test can only be true for `gawk'. It is false if using `FS' or `FPAT',
+or on some other `awk' implementation.
The code that checks for using `FPAT', using `using_fpat' and
`PROCINFO["FS"]', is similar.
@@ -15793,8 +16036,7 @@ the same names:
# group.awk --- functions for dealing with the group file
- BEGIN \
- {
+ BEGIN {
# Change to suit your system
_gr_awklib = "/usr/local/libexec/awk/"
}
@@ -15827,8 +16069,7 @@ the same names:
n = split($4, a, "[ \t]*,[ \t]*")
for (i = 1; i <= n; i++)
if (a[i] in _gr_groupsbyuser)
- _gr_groupsbyuser[a[i]] = \
- _gr_groupsbyuser[a[i]] " " $1
+ _gr_groupsbyuser[a[i]] = gr_groupsbyuser[a[i]] " " $1
else
_gr_groupsbyuser[a[i]] = $1
@@ -15990,22 +16231,22 @@ value. Here is a main program to demonstrate:
When run, the program produces the following output:
$ gawk -f walk_array.awk
- -| a[4][1][1] = 411
- -| a[4][2] = 42
-| a[1] = 1
-| a[2][1] = 21
-| a[2][2] = 22
-| a[3] = 3
+ -| a[4][1][1] = 411
+ -| a[4][2] = 42

-File: gawk.info, Node: Library Functions Summary, Next: Library exercises, Prev: Walking Arrays, Up: Library Functions
+File: gawk.info, Node: Library Functions Summary, Next: Library Exercises, Prev: Walking Arrays, Up: Library Functions
10.8 Summary
============
* Reading programs is an excellent way to learn Good Programming.
- The functions provided in this major node and the next are intended
- to serve that purpose.
+ The functions and programs provided in this major node and the next
+ are intended to serve that purpose.
* When writing general-purpose library functions, put some thought
into how to name any global variables so that they won't conflict
@@ -16035,7 +16276,7 @@ File: gawk.info, Node: Library Functions Summary, Next: Library exercises, Pr

-File: gawk.info, Node: Library exercises, Prev: Library Functions Summary, Up: Library Functions
+File: gawk.info, Node: Library Exercises, Prev: Library Functions Summary, Up: Library Functions
10.9 Exercises
==============
@@ -16196,18 +16437,13 @@ supplied:
#
# Requires getopt() and join() library functions
- function usage( e1, e2)
+ function usage()
{
- e1 = "usage: cut [-f list] [-d c] [-s] [files...]"
- e2 = "usage: cut [-c list] [files...]"
- print e1 > "/dev/stderr"
- print e2 > "/dev/stderr"
+ print("usage: cut [-f list] [-d c] [-s] [files...]") > "/dev/stderr"
+ print("usage: cut [-c list] [files...]") > "/dev/stderr"
exit 1
}
-The variables `e1' and `e2' are used so that the function fits nicely
-on the screen.
-
Next comes a `BEGIN' rule that parses the command-line options. It
sets `FS' to a single TAB character, because that is `cut''s default
field separator. The rule then sets the output field separator to be the
@@ -16217,8 +16453,7 @@ through the command-line options. Exactly one of the variables
should be done by fields or by characters, respectively. When cutting
by characters, the output field separator is set to the null string:
- BEGIN \
- {
+ BEGIN {
FS = "\t" # default
OFS = FS
while ((c = getopt(ARGC, ARGV, "sf:c:d:")) != -1) {
@@ -16451,7 +16686,7 @@ Function::).
The program begins with a descriptive comment and then a `BEGIN' rule
that processes the command-line arguments with `getopt()'. The `-i'
(ignore case) option is particularly easy with `gawk'; we just use the
-`IGNORECASE' built-in variable (*note Built-in Variables::):
+`IGNORECASE' predefined variable (*note Built-in Variables::):
# egrep.awk --- simulate egrep in awk
#
@@ -16603,32 +16838,20 @@ line is printed, with a leading file name and colon if necessary:
The `END' rule takes care of producing the correct exit status. If
there are no matches, the exit status is one; otherwise it is zero:
- END \
- {
+ END {
exit (total == 0)
}
The `usage()' function prints a usage message in case of invalid
options, and then exits:
- function usage( e)
+ function usage()
{
- e = "Usage: egrep [-csvil] [-e pat] [files ...]"
- e = e "\n\tegrep [-csvil] pat [files ...]"
- print e > "/dev/stderr"
+ print("Usage: egrep [-csvil] [-e pat] [files ...]") > "/dev/stderr"
+ print("\n\tegrep [-csvil] pat [files ...]") > "/dev/stderr"
exit 1
}
- The variable `e' is used so that the function fits nicely on the
-printed page.
-
- Just a note on programming style: you may have noticed that the `END'
-rule uses backslash continuation, with the open brace on a line by
-itself. This is so that it more closely resembles the way functions
-are written. Many of the examples in this major node use this style.
-You can decide for yourself if you like writing your `BEGIN' and `END'
-rules this way or not.
-
---------- Footnotes ----------
(1) It also introduces a subtle bug; if a match happens, we output
@@ -16671,8 +16894,7 @@ and the group numbers:
# uid=12(foo) euid=34(bar) gid=3(baz) \
# egid=5(blat) groups=9(nine),2(two),1(one)
- BEGIN \
- {
+ BEGIN {
uid = PROCINFO["uid"]
euid = PROCINFO["euid"]
gid = PROCINFO["gid"]
@@ -16680,26 +16902,22 @@ and the group numbers:
printf("uid=%d", uid)
pw = getpwuid(uid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
if (euid != uid) {
printf(" euid=%d", euid)
pw = getpwuid(euid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
}
printf(" gid=%d", gid)
pw = getgrgid(gid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
if (egid != gid) {
printf(" egid=%d", egid)
pw = getgrgid(egid)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
}
for (i = 1; ("group" i) in PROCINFO; i++) {
@@ -16708,8 +16926,7 @@ and the group numbers:
group = PROCINFO["group" i]
printf("%d", group)
pw = getgrgid(group)
- if (pw != "")
- pr_first_field(pw)
+ pr_first_field(pw)
if (("group" (i+1)) in PROCINFO)
printf(",")
}
@@ -16719,8 +16936,10 @@ and the group numbers:
function pr_first_field(str, a)
{
- split(str, a, ":")
- printf("(%s)", a[1])
+ if (str != "") {
+ split(str, a, ":")
+ printf("(%s)", a[1])
+ }
}
The test in the `for' loop is worth noting. Any supplementary
@@ -16738,8 +16957,9 @@ then the condition is false the first time it's tested, and the loop
body never executes.
The `pr_first_field()' function simply isolates out some code that
-is used repeatedly, making the whole program slightly shorter and
-cleaner.
+is used repeatedly, making the whole program shorter and cleaner. In
+particular, moving the check for the empty string into this function
+saves several lines of code.

File: gawk.info, Node: Split Program, Next: Tee Program, Prev: Id Program, Up: Clones
@@ -16830,15 +17050,12 @@ moves to the next letter in the alphabet and `s2' starts over again at
The `usage()' function simply prints an error message and exits:
- function usage( e)
+ function usage()
{
- e = "usage: split [-num] [file] [outname]"
- print e > "/dev/stderr"
+ print("usage: split [-num] [file] [outname]") > "/dev/stderr"
exit 1
}
-The variable `e' is used so that the function fits nicely on the screen.
-
This program is a bit sloppy; it relies on `awk' to automatically
close the last file instead of doing it in an `END' rule. It also
assumes that letters are contiguous in the character set, which isn't
@@ -16880,8 +17097,7 @@ input by setting `ARGV[1]' to `"-"' and `ARGC' to two:
# Copy standard input to all named output files.
# Append content if -a option is supplied.
#
- BEGIN \
- {
+ BEGIN {
for (i = 1; i < ARGC; i++)
copy[i] = ARGV[i]
@@ -16931,8 +17147,7 @@ N input records and M output files, the first method only executes N
Finally, the `END' rule cleans up by closing all the output files:
- END \
- {
+ END {
for (i in copy)
close(copy[i])
}
@@ -16953,10 +17168,10 @@ usage is as follows:
The options for `uniq' are:
`-d'
- Print only repeated lines.
+ Print only repeated (duplicated) lines.
`-u'
- Print only nonrepeated lines.
+ Print only nonrepeated (unique) lines.
`-c'
Count lines. This option overrides `-d' and `-u'. Both repeated
@@ -17006,10 +17221,9 @@ standard output, `/dev/stdout':
#
# Requires getopt() and join() library functions
- function usage( e)
+ function usage()
{
- e = "Usage: uniq [-udc [-n]] [+n] [ in [ out ]]"
- print e > "/dev/stderr"
+ print("Usage: uniq [-udc [-n]] [+n] [ in [ out ]]") > "/dev/stderr"
exit 1
}
@@ -17019,8 +17233,7 @@ standard output, `/dev/stdout':
# -n skip n fields
# +n skip n characters, skip fields first
- BEGIN \
- {
+ BEGIN {
count = 1
outputfile = "/dev/stdout"
opts = "udc0:1:2:3:4:5:6:7:8:9:"
@@ -17032,7 +17245,7 @@ standard output, `/dev/stdout':
else if (c == "c")
do_count++
else if (index("0123456789", c) != 0) {
- # getopt requires args to options
+ # getopt() requires args to options
# this messes us up for things like -5
if (Optarg ~ /^[[:digit:]]+$/)
fcount = (c Optarg) + 0
@@ -17064,16 +17277,18 @@ standard output, `/dev/stdout':
The following function, `are_equal()', compares the current line,
`$0', to the previous line, `last'. It handles skipping fields and
characters. If no field count and no character count are specified,
-`are_equal()' simply returns one or zero depending upon the result of a
-simple string comparison of `last' and `$0'. Otherwise, things get more
-complicated. If fields have to be skipped, each line is broken into an
-array using `split()' (*note String Functions::); the desired fields
-are then joined back into a line using `join()'. The joined lines are
-stored in `clast' and `cline'. If no fields are skipped, `clast' and
-`cline' are set to `last' and `$0', respectively. Finally, if
-characters are skipped, `substr()' is used to strip off the leading
-`charcount' characters in `clast' and `cline'. The two strings are
-then compared and `are_equal()' returns the result:
+`are_equal()' returns one or zero depending upon the result of a simple
+string comparison of `last' and `$0'.
+
+ Otherwise, things get more complicated. If fields have to be
+skipped, each line is broken into an array using `split()' (*note
+String Functions::); the desired fields are then joined back into a line
+using `join()'. The joined lines are stored in `clast' and `cline'.
+If no fields are skipped, `clast' and `cline' are set to `last' and
+`$0', respectively. Finally, if characters are skipped, `substr()' is
+used to strip off the leading `charcount' characters in `clast' and
+`cline'. The two strings are then compared and `are_equal()' returns
+the result:
function are_equal( n, m, clast, cline, alast, aline)
{
@@ -17169,8 +17384,8 @@ one or more input files. Its usage is as follows:
If no files are specified on the command line, `wc' reads its
standard input. If there are multiple files, it also prints total
-counts for all the files. The options and their meanings are shown in
-the following list:
+counts for all the files. The options and their meanings are as
+follows:
`-l'
Count only lines.
@@ -17408,8 +17623,7 @@ Statement::), but the processing could be done with a series of
# Requires getlocaltime() library function
# usage: alarm time [ "message" [ count [ delay ] ] ]
- BEGIN \
- {
+ BEGIN {
# Initial argument sanity checking
usage1 = "usage: alarm time ['message' [count [delay]]]"
usage2 = sprintf("\t(%s) time ::= hh:mm", ARGV[1])
@@ -17527,17 +17741,17 @@ there are more characters in the "from" list than in the "to" list, the
last character of the "to" list is used for the remaining characters in
the "from" list.
- Once upon a time, a user proposed that a transliteration function
-should be added to `gawk'. The following program was written to prove
-that character transliteration could be done with a user-level
-function. This program is not as complete as the system `tr' utility
-but it does most of the job.
+ Once upon a time, a user proposed adding a transliteration function
+to `gawk'. The following program was written to prove that character
+transliteration could be done with a user-level function. This program
+is not as complete as the system `tr' utility but it does most of the
+job.
- The `translate' program demonstrates one of the few weaknesses of
-standard `awk': dealing with individual characters is very painful,
-requiring repeated use of the `substr()', `index()', and `gsub()'
-built-in functions (*note String Functions::).(2) There are two
-functions. The first, `stranslate()', takes three arguments:
+ The `translate' program was written long before `gawk' acquired the
+ability to split each character in a string into separate array
+elements. Thus, it makes repeated use of the `substr()', `index()',
+and `gsub()' built-in functions (*note String Functions::). There are
+two functions. The first, `stranslate()', takes three arguments:
`from'
A list of characters from which to translate.
@@ -17554,10 +17768,10 @@ simple loop goes through `from', one character at a time. For each
character in `from', if the character appears in `target', it is
replaced with the corresponding `to' character.
- The `translate()' function simply calls `stranslate()' using `$0' as
-the target. The main program sets two global variables, `FROM' and
-`TO', from the command line, and then changes `ARGV' so that `awk'
-reads from the standard input.
+ The `translate()' function calls `stranslate()' using `$0' as the
+target. The main program sets two global variables, `FROM' and `TO',
+from the command line, and then changes `ARGV' so that `awk' reads from
+the standard input.
Finally, the processing rule simply calls `translate()' for each
record:
@@ -17623,6 +17837,10 @@ array only once, in a `BEGIN' rule. However, this assumes that the
"from" and "to" lists will never change throughout the lifetime of the
program.
+ Another obvious improvement is to enable the use of ranges, such as
+`a-z', as allowed by the `tr' utility. Look at the code for `cut.awk'
+(*note Cut Program::) for inspiration.
+
---------- Footnotes ----------
(1) On some older systems, including Solaris, the system version of
@@ -17630,9 +17848,6 @@ program.
enclosed in square brackets (`[a-z]') and quoted, to prevent the shell
from attempting a file name expansion. This is not a feature.
- (2) This program was written before `gawk' acquired the ability to
-split each character in a string into separate array elements.
-

File: gawk.info, Node: Labels Program, Next: Word Sorting, Prev: Translate Program, Up: Miscellaneous Programs
@@ -17658,12 +17873,12 @@ splits records at blank lines (*note Records::). It sets `MAXLINES' to
Most of the work is done in the `printpage()' function. The label
lines are stored sequentially in the `line' array. But they have to
print horizontally; `line[1]' next to `line[6]', `line[2]' next to
-`line[7]', and so on. Two loops are used to accomplish this. The
-outer loop, controlled by `i', steps through every 10 lines of data;
-this is each row of labels. The inner loop, controlled by `j', goes
-through the lines within the row. As `j' goes from 0 to 4, `i+j' is
-the `j'-th line in the row, and `i+j+5' is the entry next to it. The
-output ends up looking something like this:
+`line[7]', and so on. Two loops accomplish this. The outer loop,
+controlled by `i', steps through every 10 lines of data; this is each
+row of labels. The inner loop, controlled by `j', goes through the
+lines within the row. As `j' goes from 0 to 4, `i+j' is the `j'-th
+line in the row, and `i+j+5' is the entry next to it. The output ends
+up looking something like this:
line 1 line 6
line 2 line 7
@@ -17730,8 +17945,7 @@ not have been an even multiple of 20 labels in the data:
Count++
}
- END \
- {
+ END {
printpage()
}
@@ -17755,7 +17969,7 @@ a useful format.
At first glance, a program like this would seem to do the job:
- # Print list of word frequencies
+ # wordfreq-first-try.awk --- print list of word frequencies
{
for (i = 1; i <= NF; i++)
@@ -17909,9 +18123,9 @@ Texinfo input file into separate files.
This Info file is written in Texinfo
(http://www.gnu.org/software/texinfo/), the GNU project's document
formatting language. A single Texinfo source file can be used to
-produce both printed and online documentation. The Texinfo language is
-described fully, starting with *note (Texinfo)Top::
-texinfo,Texinfo--The GNU Documentation Format.
+produce both printed documentation, with TeX, and online documentation.
+(The Texinfo language is described fully, starting with *note
+(Texinfo)Top:: texinfo,Texinfo--The GNU Documentation Format.)
For our purposes, it is enough to know three things about Texinfo
input files:
@@ -17973,13 +18187,11 @@ upper- and lowercase letters in the directives won't matter.
given (`NF' is at least three) and also checking that the command exits
with a zero exit status, signifying OK:
- # extract.awk --- extract files and run programs
- # from texinfo files
+ # extract.awk --- extract files and run programs from texinfo files
BEGIN { IGNORECASE = 1 }
- /^@c(omment)?[ \t]+system/ \
- {
+ /^@c(omment)?[ \t]+system/ {
if (NF < 3) {
e = ("extract: " FILENAME ":" FNR)
e = (e ": badly formed `system' line")
@@ -18027,8 +18239,7 @@ with the value of `SUBSEP' (*note Multidimensional::), to rejoin the
pieces back into a single line. That line is then printed to the
output file:
- /^@c(omment)?[ \t]+file/ \
- {
+ /^@c(omment)?[ \t]+file/ {
if (NF != 3) {
e = ("extract: " FILENAME ":" FNR ": badly formed `file' line")
print e > "/dev/stderr"
@@ -18082,7 +18293,7 @@ closing the open file:
function unexpected_eof()
{
printf("extract: %s:%d: unexpected EOF or error\n",
- FILENAME, FNR) > "/dev/stderr"
+ FILENAME, FNR) > "/dev/stderr"
exit 1
}
@@ -18104,7 +18315,7 @@ pipeline of commands. While `sed' is a complicated program in its own
right, its most common use is to perform global substitutions in the
middle of a pipeline:
- command1 < orig.data | sed 's/old/new/g' | command2 > result
+ COMMAND1 < orig.data | sed 's/old/new/g' | COMMAND2 > result
Here, `s/old/new/g' tells `sed' to look for the regexp `old' on each
input line and globally replace it with the text `new', i.e., all the
@@ -18291,8 +18502,8 @@ arguments are supplied, then the first nonoption argument should be the
`awk' program. If there are no command-line arguments left, `igawk'
prints an error message and exits. Otherwise, the first argument is
appended to `program'. In any case, after the arguments have been
-processed, `program' contains the complete text of the original `awk'
-program.
+processed, the shell variable `program' contains the complete text of
+the original `awk' program.
The program is as follows:
@@ -18538,7 +18749,7 @@ and it is frequently easier to do certain kinds of string and argument
manipulation using the shell than it is in `awk'.
Finally, `igawk' shows that it is not always necessary to add new
-features to a program; they can often be layered on top.
+features to a program; they can often be layered on top.(3)
---------- Footnotes ----------
@@ -18547,7 +18758,10 @@ 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.
+
+ (3) `gawk' does `@include' processing itself in order to support the
+use of `awk' programs as Web CGI scripts.

File: gawk.info, Node: Anagram Program, Next: Signature Program, Prev: Igawk Program, Up: Miscellaneous Programs
@@ -18560,12 +18774,11 @@ word list (such as `/usr/share/dict/words' on many GNU/Linux systems).
One word is an anagram of another if both words contain the same letters
(for example, "babbling" and "blabbing").
- An elegant algorithm is presented in Column 2, Problem C of Jon
-Bentley's `Programming Pearls', second edition. The idea is to give
-words that are anagrams a common signature, sort all the words together
-by their signature, and then print them. Dr. Bentley observes that
-taking the letters in each word and sorting them produces that common
-signature.
+ Column 2, Problem C of Jon Bentley's `Programming Pearls', second
+edition, presents an elegant algorithm. The idea is to give words that
+are anagrams a common signature, sort all the words together by their
+signature, and then print them. Dr. Bentley observes that taking the
+letters in each word and sorting them produces that common signature.
The following program uses arrays of arrays to bring together words
with the same signature and array sorting to print the words in sorted
@@ -18674,9 +18887,9 @@ File: gawk.info, Node: Programs Summary, Next: Programs Exercises, Prev: Misc
11.4 Summary
============
- * The functions provided in this major node and the previous one
- continue on the theme that reading programs is an excellent way to
- learn Good Programming.
+ * The programs provided in this major node continue on the theme
+ that reading programs is an excellent way to learn Good
+ Programming.
* Using `#!' to make `awk' programs directly runnable makes them
easier to use. Otherwise, invoke the program using `awk -f ...'.
@@ -18705,7 +18918,7 @@ File: gawk.info, Node: Programs Exercises, Prev: Programs Summary, Up: Sample
==============
1. Rewrite `cut.awk' (*note Cut Program::) using `split()' with `""'
- as the seperator.
+ as the separator.
2. In *note Egrep Program::, we mentioned that `egrep -i' could be
simulated in versions of `awk' without `IGNORECASE' by using
@@ -18718,14 +18931,21 @@ File: gawk.info, Node: Programs Exercises, Prev: Programs Summary, Up: Sample
Program::) to accept the same arguments and perform in the same
way.
- 4. The `split.awk' program (*note Split Program::) uses the `chr()'
- and `ord()' functions to move through the letters of the alphabet.
- Modify the program to instead use only the `awk' built-in
- functions, such as `index()' and `substr()'.
-
- 5. The `split.awk' program (*note Split Program::) assumes that
+ 4. The `split.awk' program (*note Split Program::) assumes that
letters are contiguous in the character set, which isn't true for
- EBCDIC systems. Fix this problem.
+ EBCDIC systems. Fix this problem. (Hint: Consider a different
+ way to work through the alphabet, without relying on `ord()' and
+ `chr()'.)
+
+ 5. In `uniq.awk' (*note Uniq Program::, the logic for choosing which
+ lines to print represents a "state machine", which is "a device
+ that can be in one of a set number of stable conditions depending
+ on its previous condition and on the present values of its
+ inputs."(1) Brian Kernighan suggests that "an alternative approach
+ to state machines is to just read the input into an array, then
+ use indexing. It's almost always easier code, and for most inputs
+ where you would use this, just as fast." Rewrite the logic to
+ follow this suggestion.
6. Why can't the `wc.awk' program (*note Wc Program::) just use the
value of `FNR' in `endfile()'? Hint: Examine the code in *note
@@ -18788,6 +19008,11 @@ File: gawk.info, Node: Programs Exercises, Prev: Programs Summary, Up: Sample
of the external `sort' utility.
+ ---------- Footnotes ----------
+
+ (1) This is the definition returned from entering `define: state
+machine' into Google.
+

File: gawk.info, Node: Advanced Features, Next: Internationalization, Prev: Sample Programs, Up: Top
@@ -18841,11 +19066,10 @@ File: gawk.info, Node: Nondecimal Data, Next: Array Sorting, Up: Advanced Fea
===================================
If you run `gawk' with the `--non-decimal-data' option, you can have
-nondecimal constants in your input data:
+nondecimal values in your input data:
$ echo 0123 123 0x123 |
- > gawk --non-decimal-data '{ printf "%d, %d, %d\n",
- > $1, $2, $3 }'
+ > gawk --non-decimal-data '{ printf "%d, %d, %d\n", $1, $2, $3 }'
-| 83, 123, 291
For this feature to work, write your program so that `gawk' treats
@@ -18876,6 +19100,8 @@ request it.
programs easier to write and easier to read, and leads to less
surprising results.
+ This option may disappear in a future version of `gawk'.
+

File: gawk.info, Node: Array Sorting, Next: Two-way I/O, Prev: Nondecimal Data, Up: Advanced Features
@@ -18914,7 +19140,7 @@ pre-defined values to `PROCINFO["sorted_in"]' in order to control the
order in which `gawk' traverses an array during a `for' loop.
In addition, the value of `PROCINFO["sorted_in"]' can be a function
-name. This lets you traverse an array based on any custom criterion.
+name.(1) This lets you traverse an array based on any custom criterion.
The array elements are ordered according to the return value of this
function. The comparison function should be defined with at least four
arguments:
@@ -19029,7 +19255,7 @@ of the previous functions:
according to login name. The following program sorts records by a
specific field position and can be used for this purpose:
- # sort.awk --- simple program to sort by field position
+ # passwd-sort.awk --- simple program to sort by field position
# field position is specified by the global variable POS
function cmp_field(i1, v1, i2, v2)
@@ -19081,13 +19307,14 @@ seemingly ordered data:
elements compare equal. This is usually not a problem, but letting the
tied elements come out in arbitrary order can be an issue, especially
when comparing item values. The partial ordering of the equal elements
-may change during the next loop traversal, if other elements are added
-or removed from the array. One way to resolve ties when comparing
-elements with otherwise equal values is to include the indices in the
-comparison rules. Note that doing this may make the loop traversal
-less efficient, so consider it only if necessary. The following
-comparison functions force a deterministic order, and are based on the
-fact that the (string) indices of two elements are never equal:
+may change the next time the array is traversed, if other elements are
+added or removed from the array. One way to resolve ties when
+comparing elements with otherwise equal values is to include the
+indices in the comparison rules. Note that doing this may make the
+loop traversal less efficient, so consider it only if necessary. The
+following comparison functions force a deterministic order, and are
+based on the fact that the (string) indices of two elements are never
+equal:
function cmp_numeric(i1, v1, i2, v2)
{
@@ -19126,6 +19353,11 @@ array has been reported to add 15% to 20% overhead to the execution
time of `awk' programs. For this reason, sorted array traversal is not
the default.
+ ---------- Footnotes ----------
+
+ (1) This is why the predefined sorting orders start with an `@'
+character, which cannot be part of an identifier.
+

File: gawk.info, Node: Array Sorting Functions, Prev: Controlling Array Traversal, Up: Array Sorting
@@ -19212,7 +19444,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 ----------
@@ -19338,7 +19570,7 @@ using regular pipes.
(1) Michael Brennan suggests the use of `rand()' to generate unique
file names. This is a valid point; nevertheless, temporary files remain
-more difficult than two-way pipes.
+more difficult to use than two-way pipes.
(2) This is very different from the same operator in the C shell and
in Bash.
@@ -19349,16 +19581,16 @@ File: gawk.info, Node: TCP/IP Networking, Next: Profiling, Prev: Two-way I/O,
12.4 Using `gawk' for Network Programming
=========================================
- `EMISTERED':
+ `EMRED':
A host is a host from coast to coast,
- and no-one can talk to host that's close,
+ and nobody talks to a host that's close,
unless the host that isn't close
- is busy hung or dead.
+ is busy, hung, or dead. -- Mike O'Brien (aka Mr. Protocol)
- In addition to being able to open a two-way pipeline to a coprocess
-on the same system (*note Two-way I/O::), it is possible to make a
-two-way connection to another process on another system across an IP
-network connection.
+In addition to being able to open a two-way pipeline to a coprocess on
+the same system (*note Two-way I/O::), it is possible to make a two-way
+connection to another process on another system across an IP network
+connection.
You can think of this as just a _very long_ two-way pipeline to a
coprocess. The way `gawk' decides that you want to use TCP/IP
@@ -19377,8 +19609,8 @@ NET-TYPE
PROTOCOL
The protocol to use over IP. This must be either `tcp', or `udp',
- for a TCP or UDP IP connection, respectively. The use of TCP is
- recommended for most applications.
+ for a TCP or UDP IP connection, respectively. TCP should be used
+ for most applications.
LOCAL-PORT
The local TCP or UDP port number to use. Use a port number of `0'
@@ -19404,10 +19636,10 @@ REMOTE-PORT
Consider the following very simple example:
BEGIN {
- Service = "/inet/tcp/0/localhost/daytime"
- Service |& getline
- print $0
- close(Service)
+ Service = "/inet/tcp/0/localhost/daytime"
+ Service |& getline
+ print $0
+ close(Service)
}
This program reads the current date and time from the local system's
@@ -19482,9 +19714,9 @@ First, the `awk' program:
profiler on this program and data. (This example also illustrates that
`awk' programmers sometimes get up very early in the morning to work.)
- # gawk profile, created Thu Feb 27 05:16:21 2014
+ # gawk profile, created Mon Sep 29 05:16:21 2014
- # BEGIN block(s)
+ # BEGIN rule(s)
BEGIN {
1 print "First BEGIN rule"
@@ -19511,7 +19743,7 @@ profiler on this program and data. (This example also illustrates that
}
}
- # END block(s)
+ # END rule(s)
END {
1 print "First END rule"
@@ -19597,7 +19829,7 @@ come out as:
print $0
}
-which is correct, but possibly surprising.
+which is correct, but possibly unexpected.
Besides creating profiles when a program has completed, `gawk' can
produce a profile while it is running. This is useful if your `awk'
@@ -19614,7 +19846,7 @@ The shell prints a job number and process ID number; in this case,
$ kill -USR1 13992
As usual, the profiled version of the program is written to
-`awkprof.out', or to a different file if one specified with the
+`awkprof.out', or to a different file if one was specified with the
`--profile' option.
Along with the regular profile, as shown earlier, the profile file
@@ -19658,7 +19890,8 @@ File: gawk.info, Node: Advanced Features Summary, Prev: Profiling, Up: Advanc
* The `--non-decimal-data' option causes `gawk' to treat octal- and
hexadecimal-looking input data as octal and hexadecimal. This
option should be used with caution or not at all; use of
- `strtonum()' is preferable.
+ `strtonum()' is preferable. Note that this option may disappear
+ in a future version of `gawk'.
* You can take over complete control of sorting in `for (INDX in
ARRAY)' array traversal by setting `PROCINFO["sorted_in"]' to the
@@ -19672,14 +19905,14 @@ 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
- a TCP/IP (or UDP/IP) connection to remote hosts in the Internet.
- `gawk' supports both IPv4 an IPv6.
+ * By using special file names with the `|&' operator, you can open a
+ TCP/IP (or UDP/IP) connection to remote hosts in the Internet.
+ `gawk' supports both IPv4 and IPv6.
* You can generate statement count profiles of your program. This
can help you determine which parts of your program may be taking
@@ -19840,7 +20073,7 @@ are:
Character-type information (alphabetic, digit, upper- or
lowercase, and so on) as well as character encoding. This
information is accessed via the POSIX character classes in regular
- expressions, such as `/[[:alnum:]]/' (*note Regexp Operators::).
+ expressions, such as `/[[:alnum:]]/' (*note Bracket Expressions::).
`LC_MONETARY'
Monetary information, such as the currency symbol, and whether the
@@ -19908,8 +20141,8 @@ internationalization:
Return the plural form used for NUMBER of the translation of
STRING1 and STRING2 in text domain DOMAIN for locale category
CATEGORY. STRING1 is the English singular variant of a message,
- and STRING2 the English plural variant of the same message. The
- default value for DOMAIN is the current value of `TEXTDOMAIN'.
+ and STRING2 is the English plural variant of the same message.
+ The default value for DOMAIN is the current value of `TEXTDOMAIN'.
The default value for CATEGORY is `"LC_MESSAGES"'.
The same remarks about argument order as for the `dcgettext()'
@@ -19962,9 +20195,11 @@ outlined in *note Explaining gettext::, like so:
one. This example would be better done with `dcngettext()':
if (groggy)
- message = dcngettext("%d customer disturbing me\n", "%d customers disturbing me\n", "adminprog")
+ message = dcngettext("%d customer disturbing me\n",
+ "%d customers disturbing me\n", "adminprog")
else
- message = dcngettext("enjoying %d customer\n", "enjoying %d customers\n", "adminprog")
+ message = dcngettext("enjoying %d customer\n",
+ "enjoying %d customers\n", "adminprog")
printf(message, ncustomers)
4. During development, you might want to put the `.gmo' file in a
@@ -20022,7 +20257,7 @@ marked and you've set (and perhaps bound) the text domain, it is time
to produce translations. First, use the `--gen-pot' command-line
option to create the initial `.pot' file:
- $ gawk --gen-pot -f guide.awk > guide.pot
+ gawk --gen-pot -f guide.awk > guide.pot
When run with `--gen-pot', `gawk' does not execute your program.
Instead, it parses it as usual and prints all marked strings to
@@ -20074,11 +20309,11 @@ example, `string' is the first argument and `length(string)' is the
second:
$ gawk 'BEGIN {
- > string = "Dont Panic"
+ > string = "Don\47t Panic"
> printf "%2$d characters live in \"%1$s\"\n",
> string, length(string)
> }'
- -| 10 characters live in "Dont Panic"
+ -| 11 characters live in "Don't Panic"
If present, positional specifiers come first in the format
specification, before the flags, the field width, and/or the precision.
@@ -20239,7 +20474,8 @@ Following are the translations:
The next step is to make the directory to hold the binary message
object file and then to create the `guide.mo' file. We pretend that
-our file is to be used in the `en_US.UTF-8' locale. The directory
+our file is to be used in the `en_US.UTF-8' locale, since we have to
+use a locale name known to the C `gettext' routines. The directory
layout shown here is standard for GNU `gettext' on GNU/Linux systems.
Other versions of `gettext' may use a different layout:
@@ -20248,7 +20484,7 @@ Other versions of `gettext' may use a different layout:
The `msgfmt' utility does the conversion from human-readable `.po'
file to machine-readable `.mo' file. By default, `msgfmt' creates a
file named `messages'. This file must be renamed and placed in the
-proper directory so that `gawk' can find it:
+proper directory (using the `-o' option) so that `gawk' can find it:
$ msgfmt guide-mellow.po -o en_US.UTF-8/LC_MESSAGES/guide.mo
@@ -20281,8 +20517,8 @@ File: gawk.info, Node: Gawk I18N, Next: I18N Summary, Prev: I18N Example, Up
`gawk' itself has been internationalized using the GNU `gettext'
package. (GNU `gettext' is described in complete detail in *note (GNU
`gettext' utilities)Top:: gettext, GNU gettext tools.) As of this
-writing, the latest version of GNU `gettext' is version 0.19.1
-(ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.1.tar.gz).
+writing, the latest version of GNU `gettext' is version 0.19.2
+(ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.2.tar.gz).
If a translation of `gawk''s messages exists, then `gawk' produces
usage messages, warnings, and fatal errors in the local language.
@@ -20367,7 +20603,7 @@ File: gawk.info, Node: Debugging Concepts, Next: Debugging Terms, Up: Debuggi
---------------------------
(If you have used debuggers in other languages, you may want to skip
-ahead to the next section on the specific features of the `awk'
+ahead to the next section on the specific features of the `gawk'
debugger.)
Of course, a debugging program cannot remove bugs for you, since it
@@ -20403,8 +20639,8 @@ functional program that you or someone else wrote).

File: gawk.info, Node: Debugging Terms, Next: Awk Debugging, Prev: Debugging Concepts, Up: Debugging
-14.1.2 Additional Debugging Concepts
-------------------------------------
+14.1.2 Debugging Concepts
+-------------------------
Before diving in to the details, we need to introduce several important
concepts that apply to just about all debuggers. The following list
@@ -20496,22 +20732,22 @@ File: gawk.info, Node: Debugger Invocation, Next: Finding The Bug, Up: Sample
14.2.1 How to Start the Debugger
--------------------------------
-Starting the debugger is almost exactly like running `gawk', except you
-have to pass an additional option `--debug' or the corresponding short
-option `-D'. The file(s) containing the program and any supporting
-code are given on the command line as arguments to one or more `-f'
-options. (`gawk' is not designed to debug command-line programs, only
-programs contained in files.) In our case, we invoke the debugger like
-this:
+Starting the debugger is almost exactly like running `gawk' normally,
+except you have to pass an additional option `--debug', or the
+corresponding short option `-D'. The file(s) containing the program
+and any supporting code are given on the command line as arguments to
+one or more `-f' options. (`gawk' is not designed to debug command-line
+programs, only programs contained in files.) In our case, we invoke
+the debugger like this:
- $ gawk -D -f getopt.awk -f join.awk -f uniq.awk inputfile
+ $ gawk -D -f getopt.awk -f join.awk -f uniq.awk -1 inputfile
where both `getopt.awk' and `uniq.awk' are in `$AWKPATH'. (Experienced
users of GDB or similar debuggers should note that this syntax is
slightly different from what they are used to. With the `gawk'
debugger, you give the arguments for running the program in the command
line to the debugger rather than as part of the `run' command at the
-debugger prompt.)
+debugger prompt.) The `-1' is an option to `uniq.awk'.
Instead of immediately running the program on `inputfile', as `gawk'
would ordinarily do, the debugger merely loads all the program source
@@ -20556,7 +20792,7 @@ for a breakpoint in `uniq.awk' is at the beginning of the function
To set the breakpoint, use the `b' (breakpoint) command:
gawk> b are_equal
- -| Breakpoint 1 set at file `awklib/eg/prog/uniq.awk', line 64
+ -| Breakpoint 1 set at file `awklib/eg/prog/uniq.awk', line 63
The debugger tells us the file and line number where the breakpoint
is. Now type `r' or `run' and the program runs until it hits the
@@ -20566,8 +20802,8 @@ breakpoint for the first time:
-| Starting program:
-| Stopping in Rule ...
-| Breakpoint 1, are_equal(n, m, clast, cline, alast, aline)
- at `awklib/eg/prog/uniq.awk':64
- -| 64 if (fcount == 0 && charcount == 0)
+ at `awklib/eg/prog/uniq.awk':63
+ -| 63 if (fcount == 0 && charcount == 0)
gawk>
Now we can look at what's going on inside our program. First of all,
@@ -20577,11 +20813,11 @@ the current stack frames:
gawk> bt
-| #0 are_equal(n, m, clast, cline, alast, aline)
- at `awklib/eg/prog/uniq.awk':69
- -| #1 in main() at `awklib/eg/prog/uniq.awk':89
+ at `awklib/eg/prog/uniq.awk':68
+ -| #1 in main() at `awklib/eg/prog/uniq.awk':88
This tells us that `are_equal()' was called by the main program at
-line 89 of `uniq.awk'. (This is not a big surprise, since this is the
+line 88 of `uniq.awk'. (This is not a big surprise, since this is the
only call to `are_equal()' in the program, but in more complex
programs, knowing who called a function and with what parameters can be
the key to finding the source of the problem.)
@@ -20600,13 +20836,13 @@ function was called without arguments (*note Function Calls::).
A more useful variable to display might be the current record:
gawk> p $0
- -| $0 = string ("gawk is a wonderful program!")
+ -| $0 = "gawk is a wonderful program!"
This might be a bit puzzling at first since this is the second line of
our test input above. Let's look at `NR':
gawk> p NR
- -| NR = number (2)
+ -| NR = 2
So we can see that `are_equal()' was only called for the second record
of the file. Of course, this is because our program contains a rule for
@@ -20620,7 +20856,7 @@ of the file. Of course, this is because our program contains a rule for
OK, let's just check that that rule worked correctly:
gawk> p last
- -| last = string ("awk is a wonderful program!")
+ -| last = "awk is a wonderful program!"
Everything we have done so far has verified that the program has
worked as planned, up to and including the call to `are_equal()', so
@@ -20629,38 +20865,39 @@ must begin "stepping through" the lines of `are_equal()'. We start by
typing `n' (for "next"):
gawk> n
- -| 67 if (fcount > 0) {
+ -| 66 if (fcount > 0) {
- This tells us that `gawk' is now ready to execute line 67, which
+ This tells us that `gawk' is now ready to execute line 66, which
decides whether to give the lines the special "field skipping" treatment
-indicated by the `-f' command-line option. (Notice that we skipped
-from where we were before at line 64 to here, since the condition in
-line 64 `if (fcount == 0 && charcount == 0)' was false.)
+indicated by the `-1' command-line option. (Notice that we skipped
+from where we were before at line 63 to here, since the condition in
+line 63 `if (fcount == 0 && charcount == 0)' was false.)
Continuing to step, we now get to the splitting of the current and
last records:
gawk> n
- -| 68 n = split(last, alast)
+ -| 67 n = split(last, alast)
gawk> n
- -| 69 m = split($0, aline)
+ -| 68 m = split($0, aline)
At this point, we should be curious to see what our records were
split into, so we try to look:
gawk> p n m alast aline
- -| n = number (5)
- -| m = number (5)
+ -| n = 5
+ -| m = untyped variable
-| alast = array, 5 elements
- -| aline = array, 5 elements
+ -| aline = untyped variable
(The `p' command can take more than one argument, similar to `awk''s
`print' statement.)
This is kind of disappointing, though. All we found out is that
-there are five elements in each of our arrays. Useful enough (we now
-know that none of the words were accidentally left out), but what if we
-want to see inside the array?
+there are five elements in `alast'; `m' and `aline' don't have values
+since we are at line 68 but haven't executed it yet. This information
+is useful enough (we now know that none of the words were accidentally
+left out), but what if we want to see inside the array?
The first choice would be to use subscripts:
@@ -20670,25 +20907,25 @@ want to see inside the array?
Oops!
gawk> p alast[1]
- -| alast["1"] = string ("awk")
+ -| alast["1"] = "awk"
This would be kind of slow for a 100-member array, though, so `gawk'
provides a shortcut (reminiscent of another language not to be
mentioned):
gawk> p @alast
- -| alast["1"] = string ("awk")
- -| alast["2"] = string ("is")
- -| alast["3"] = string ("a")
- -| alast["4"] = string ("wonderful")
- -| alast["5"] = string ("program!")
+ -| alast["1"] = "awk"
+ -| alast["2"] = "is"
+ -| alast["3"] = "a"
+ -| alast["4"] = "wonderful"
+ -| alast["5"] = "program!"
It looks like we got this far OK. Let's take another step or two:
gawk> n
- -| 70 clast = join(alast, fcount, n)
+ -| 69 clast = join(alast, fcount, n)
gawk> n
- -| 71 cline = join(aline, fcount, m)
+ -| 70 cline = join(aline, fcount, m)
Well, here we are at our error (sorry to spoil the suspense). What
we had in mind was to join the fields starting from the second one to
@@ -20696,8 +20933,8 @@ make the virtual record to compare, and if the first field was numbered
zero, this would work. Let's look at what we've got:
gawk> p cline clast
- -| cline = string ("gawk is a wonderful program!")
- -| clast = string ("awk is a wonderful program!")
+ -| cline = "gawk is a wonderful program!"
+ -| clast = "awk is a wonderful program!"
Hey, those look pretty familiar! They're just our original,
unaltered, input records. A little thinking (the human brain is still
@@ -20810,13 +21047,13 @@ controlling breakpoints are:
`condition' N `"EXPRESSION"'
Add a condition to existing breakpoint or watchpoint N. The
- condition is an `awk' expression that the debugger evaluates
- whenever the breakpoint or watchpoint is reached. If the condition
- is true, then the debugger stops execution and prompts for a
- command. Otherwise, the debugger continues executing the program.
- If the condition expression is not specified, any existing
- condition is removed; i.e., the breakpoint or watchpoint is made
- unconditional.
+ condition is an `awk' expression _enclosed in double quotes_ that
+ the debugger evaluates whenever the breakpoint or watchpoint is
+ reached. If the condition is true, then the debugger stops
+ execution and prompts for a command. Otherwise, the debugger
+ continues executing the program. If the condition expression is
+ not specified, any existing condition is removed; i.e., the
+ breakpoint or watchpoint is made unconditional.
`delete' [N1 N2 ...] [N-M]
`d' [N1 N2 ...] [N-M]
@@ -20935,9 +21172,9 @@ execution of the program than we saw in our earlier example:
`until' [[FILENAME`:']N | FUNCTION]
`u' [[FILENAME`:']N | FUNCTION]
Without any argument, continue execution until a line past the
- current line in current stack frame is reached. With an argument,
- continue execution until the specified location is reached, or the
- current stack frame returns.
+ current line in the current stack frame is reached. With an
+ argument, continue execution until the specified location is
+ reached, or the current stack frame returns.

File: gawk.info, Node: Viewing And Changing Data, Next: Execution Stack, Prev: Debugger Execution Control, Up: List of Debugger Commands
@@ -20984,9 +21221,9 @@ AWK STATEMENTS
This prints the third field in the input record (if the specified
field does not exist, it prints `Null field'). A variable can be
- an array element, with the subscripts being constant values. To
- print the contents of an array, prefix the name of the array with
- the `@' symbol:
+ an array element, with the subscripts being constant string
+ values. To print the contents of an array, prefix the name of the
+ array with the `@' symbol:
gawk> print @a
@@ -21031,7 +21268,7 @@ AWK STATEMENTS

File: gawk.info, Node: Execution Stack, Next: Debugger Info, Prev: Viewing And Changing Data, Up: List of Debugger Commands
-14.3.4 Dealing with the Stack
+14.3.4 Working with the Stack
-----------------------------
Whenever you run a program which contains any function calls, `gawk'
@@ -21043,11 +21280,13 @@ are:
`backtrace' [COUNT]
`bt' [COUNT]
+`where' [COUNT]
Print a backtrace of all function calls (stack frames), or
innermost COUNT frames if COUNT > 0. Print the outermost COUNT
frames if COUNT < 0. The backtrace displays the name and
arguments to each function, the source file name, and the line
- number.
+ number. The alias `where' for `backtrace' is provided for
+ long-time GDB users who may be used to that command.
`down' [COUNT]
Move COUNT (default 1) frames down the stack toward the innermost
@@ -21084,7 +21323,7 @@ know:
The value for WHAT should be one of the following:
`args'
- Arguments of the selected frame.
+ List arguments of the selected frame.
`break'
List all currently set breakpoints.
@@ -21093,19 +21332,19 @@ know:
List all items in the automatic display list.
`frame'
- Description of the selected stack frame.
+ Give a description of the selected stack frame.
`functions'
List all function definitions including source file names and
line numbers.
`locals'
- Local variables of the selected frame.
+ List local variables of the selected frame.
`source'
- The name of the current source file. Each time the program
- stops, the current source file is the file containing the
- current instruction. When the debugger first starts, the
+ Print the name of the current source file. Each time the
+ program stops, the current source file is the file containing
+ the current instruction. When the debugger first starts, the
current source file is the first file included via the `-f'
option. The `list FILENAME:LINENO' command can be used at any
time to change the current source.
@@ -21253,7 +21492,7 @@ categories, as follows:
or the file named FILENAME. The possible arguments to `list' are
as follows:
- `-'
+ `-' (Minus)
Print lines before the lines last printed.
`+'
@@ -21324,8 +21563,8 @@ Variable name completion

File: gawk.info, Node: Limitations, Next: Debugging Summary, Prev: Readline Support, Up: Debugger
-14.5 Limitations and Future Plans
-=================================
+14.5 Limitations
+================
We hope you find the `gawk' debugger useful and enjoyable to work with,
but as with any program, especially in its early releases, it still has
@@ -21337,7 +21576,7 @@ some limitations. A few which are worth being aware of are:
what your mistake was, though, you'll feel like a real guru.
* If you perused the dump of opcodes in *note Miscellaneous Debugger
- Commands::, (or if you are already familiar with `gawk' internals),
+ Commands:: (or if you are already familiar with `gawk' internals),
you will realize that much of the internal manipulation of data in
`gawk', as in many interpreters, is done on a stack. `Op_push',
`Op_pop', etc., are the "bread and butter" of most `gawk' code.
@@ -21364,10 +21603,6 @@ some limitations. A few which are worth being aware of are:
* The `gawk' debugger only accepts source supplied with the `-f'
option.
- Look forward to a future release when these and other missing
-features may be added, and of course feel free to try to add them
-yourself!
-

File: gawk.info, Node: Debugging Summary, Prev: Limitations, Up: Debugger
@@ -21404,8 +21639,7 @@ File: gawk.info, Node: Arbitrary Precision Arithmetic, Next: Dynamic Extension
************************************************************
This major node introduces some basic concepts relating to how
-computers do arithmetic and briefly lists the features in `gawk' for
-performing arbitrary precision floating point computations. It then
+computers do arithmetic and defines some important terms. It then
proceeds to describe floating-point arithmetic, which is what `awk'
uses for all its computations, including a discussion of arbitrary
precision floating point arithmetic, which is a feature available only
@@ -21500,9 +21734,10 @@ Floating point arithmetic
ranges. Integer values are usually either 32 or 64 bits in size. Single
precision floating point values occupy 32 bits, whereas double precision
floating point values occupy 64 bits. Floating point values are always
-signed. The possible ranges of values are shown in the following table.
+signed. The possible ranges of values are shown in *note
+table-numeric-ranges::.
-Numeric representation Miniumum value Maximum value
+Numeric representation Minimum value Maximum value
---------------------------------------------------------------------------
32-bit signed integer -2,147,483,648 2,147,483,647
32-bit unsigned integer 0 4,294,967,295
@@ -21515,6 +21750,8 @@ Double precision `2.225074e-308' `1.797693e+308'
floating point
(approximate)
+Table 15.1: Value Ranges for Different Numeric Representations
+
---------- Footnotes ----------
(1) We don't know why they expect this, but they do.
@@ -21547,7 +21784,7 @@ material here.
number and infinity produce infinity.
"NaN"
- "Not A Number."(1). A special value that results from attempting a
+ "Not A Number."(1) A special value that results from attempting a
calculation that has no answer as a real number. In such a case,
programs can either receive a floating-point exception, or get
`NaN' back as the result. The IEEE 754 standard recommends that
@@ -21605,37 +21842,38 @@ ranges. (`awk' uses only the 64-bit double precision format.)
*note table-ieee-formats:: lists the precision and exponent field
values for the basic IEEE 754 binary formats:
-Name Total bits Precision emin emax
+Name Total bits Precision Minimum Maximum
+ exponent exponent
---------------------------------------------------------------------------
Single 32 24 -126 +127
Double 64 53 -1022 +1023
Quadruple 128 113 -16382 +16383
-Table 15.1: Basic IEEE Format Context Values
+Table 15.2: Basic IEEE Format Values
NOTE: The precision numbers include the implied leading one that
gives them one extra bit of significand.
---------- Footnotes ----------
- (1) Thanks to Michael Brennan for this description, which I have
-paraphrased, and for the examples
+ (1) Thanks to Michael Brennan for this description, which we have
+paraphrased, and for the examples.

File: gawk.info, Node: MPFR features, Next: FP Math Caution, Prev: Math Definitions, Up: Arbitrary Precision Arithmetic
-15.3 Arbitrary Precison Arithmetic Features In `gawk'
-=====================================================
+15.3 Arbitrary Precision Arithmetic Features In `gawk'
+======================================================
-By default, `gawk' uses the double precision floating point values
+By default, `gawk' uses the double precision floating-point values
supplied by the hardware of the system it runs on. However, if it was
-compiled to do, `gawk' uses the GNU MPFR (http://www.mpfr.org) and GNU
-MP (http://gmplib.org) (GMP) libraries for arbitrary precision
+compiled to do so, `gawk' uses the `http://www.mpfr.org GNU MPFR' and
+GNU MP (http://gmplib.org) (GMP) libraries for arbitrary precision
arithmetic on numbers. You can see if MPFR support is available like
so:
$ gawk --version
- -| GNU Awk 4.1.1, API: 1.1 (GNU MPFR 3.1.0-p3, GNU MP 5.0.2)
+ -| GNU Awk 4.1.2, API: 1.1 (GNU MPFR 3.1.0-p3, GNU MP 5.0.2)
-| Copyright (C) 1989, 1991-2014 Free Software Foundation.
...
@@ -21653,10 +21891,11 @@ platform-independent results. With the `-M' command-line option, all
floating-point arithmetic operators and numeric functions can yield
results to any desired precision level supported by MPFR.
- Two built-in variables, `PREC' and `ROUNDMODE', provide control over
-the working precision and the rounding mode. The precision and the
-rounding mode are set globally for every operation to follow. *Note
-Auto-set::, for more information.
+ Two predefined variables, `PREC' and `ROUNDMODE', provide control
+over the working precision and the rounding mode. The precision and
+the rounding mode are set globally for every operation to follow.
+*Note Setting precision::, and *note Setting the rounding mode::, for
+more information.

File: gawk.info, Node: FP Math Caution, Next: Arbitrary Precision Integers, Prev: MPFR features, Up: Arbitrary Precision Arithmetic
@@ -21770,6 +22009,9 @@ you. Code to do this looks something like this:
else
# not ok
+(We assume that you have a simple absolute value function named `abs()'
+defined elsewhere in your program.)
+

File: gawk.info, Node: Errors accumulate, Prev: Comparing FP Values, Up: Inexactness of computations
@@ -21852,7 +22094,7 @@ forget that the finite number of bits used to store the value is often
just an approximation after proper rounding. The test for equality
succeeds if and only if _all_ bits in the two operands are exactly the
same. Since this is not necessarily true after floating-point
-computations with a particular precision and effective rounding rule, a
+computations with a particular precision and effective rounding mode, a
straight test for equality may not work. Instead, compare the two
numbers to see if they are within the desirable delta of each other.
@@ -21915,7 +22157,7 @@ File: gawk.info, Node: Setting precision, Next: Setting the rounding mode, Pr
precision or accuracy of individual numbers. Performing an arithmetic
operation or calling a built-in function rounds the result to the
current working precision. The default working precision is 53 bits,
-which you can modify using the built-in variable `PREC'. You can also
+which you can modify using the predefined variable `PREC'. You can also
set the value to one of the predefined case-insensitive strings shown
in *note table-predefined-precision-strings::, to emulate an IEEE 754
binary format.
@@ -21928,7 +22170,7 @@ binary format.
`"quad"' Basic 128-bit quadruple precision.
`"oct"' 256-bit octuple precision.
-Table 15.2: Predefined Precision Strings For `PREC'
+Table 15.3: Predefined Precision Strings For `PREC'
The following example illustrates the effects of changing precision
on arithmetic operations:
@@ -21942,7 +22184,7 @@ on arithmetic operations:
floating-point constant from program source code, `gawk' uses the
default precision (that of a C `double'), unless overridden by an
assignment to the special variable `PREC' on the command line, to
- store it internally as a MPFR number. Changing the precision
+ store it internally as an MPFR number. Changing the precision
using `PREC' in the program text does _not_ change the precision
of a constant.
@@ -21981,10 +22223,10 @@ Round toward zero `roundTowardZero' `"Z"' or `"z"'
Round to nearest, ties away `roundTiesToAway' `"A"' or `"a"'
from zero
-Table 15.3: `gawk' Rounding Modes
+Table 15.4: `gawk' Rounding Modes
`ROUNDMODE' has the default value `"N"', which selects the IEEE 754
-rounding mode `roundTiesToEven'. In *note Table 15.3:
+rounding mode `roundTiesToEven'. In *note Table 15.4:
table-gawk-rounding-modes, the value `"A"' selects `roundTiesToAway'.
This is only available if your version of the MPFR library supports it;
otherwise setting `ROUNDMODE' to `"A"' has no effect.
@@ -22063,15 +22305,15 @@ using GMP arbitrary precision integers. Any number that looks like an
integer in a source or data file is stored as an arbitrary precision
integer. The size of the integer is limited only by the available
memory. For example, the following computes 5^4^3^2, the result of
-which is beyond the limits of ordinary hardware double-precision
+which is beyond the limits of ordinary hardware double precision
floating point values:
$ gawk -M 'BEGIN {
> x = 5^4^3^2
- > print "# of digits =", length(x)
+ > print "number of digits =", length(x)
> print substr(x, 1, 20), "...", substr(x, length(x) - 19, 20)
> }'
- -| # of digits = 183231
+ -| number of digits = 183231
-| 62060698786608744707 ... 92256259918212890625
If instead you were to compute the same value using arbitrary
@@ -22133,7 +22375,7 @@ user-defined function:
# div --- do integer division
- function div(numerator, denominator, result, i)
+ function div(numerator, denominator, result)
{
split("", result)
@@ -22145,6 +22387,39 @@ user-defined function:
return 0.0
}
+ The following example program, contributed by Katie Wasserman, uses
+`div()' to compute the digits of pi to as many places as you choose to
+set:
+
+ # pi.awk --- compute the digits of pi
+
+ BEGIN {
+ digits = 100000
+ two = 2 * 10 ^ digits
+ pi = two
+ for (m = digits * 4; m > 0; --m) {
+ d = m * 2 + 1
+ x = pi * m
+ div(x, d, result)
+ pi = result["quotient"]
+ pi = pi + two
+ }
+ print pi
+ }
+
+ When asked about the algorithm used, Katie replied:
+
+ It's not that well known but it's not that obscure either. It's
+ Euler's modification to Newton's method for calculating pi. Take
+ a look at lines (23) - (25) here:
+ `http://mathworld.wolfram.com/PiFormulas.htm'.
+
+ The algorithm I wrote simply expands the multiply by 2 and works
+ from the innermost expression outwards. I used this to program HP
+ calculators because it's quite easy to modify for tiny memory
+ devices with smallish word sizes. See
+ `http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=899'.
+
---------- Footnotes ----------
(1) Weisstein, Eric W. `Sylvester's Sequence'. From MathWorld--A
@@ -22246,8 +22521,8 @@ File: gawk.info, Node: Floating point summary, Prev: POSIX Floating Point Prob
============
* Most computer arithmetic is done using either integers or
- floating-point values. The default for `awk' is to use
- double-precision floating-point values.
+ floating-point values. Standard `awk' uses double precision
+ floating-point values.
* In the early 1990's, Barbie mistakenly said "Math class is tough!"
While math isn't tough, floating-point arithmetic isn't the same
@@ -22348,7 +22623,7 @@ write in C or C++, you can write an extension to do it!
Extensions are written in C or C++, using the "Application
Programming Interface" (API) defined for this purpose by the `gawk'
developers. The rest of this major node explains the facilities that
-the API provides and how to use them, and presents a small sample
+the API provides and how to use them, and presents a small example
extension. In addition, it documents the sample extensions included in
the `gawk' distribution, and describes the `gawkextlib' project. *Note
Extension Design::, for a discussion of the extension mechanism goals
@@ -22360,10 +22635,13 @@ File: gawk.info, Node: Plugin License, Next: Extension Mechanism Outline, Pre
16.2 Extension Licensing
========================
-Every dynamic extension should define the global symbol
-`plugin_is_GPL_compatible' to assert that it has been licensed under a
-GPL-compatible license. If this symbol does not exist, `gawk' emits a
-fatal error and exits when it tries to load your extension.
+Every dynamic extension must be distributed under a license that is
+compatible with the GNU GPL (*note Copying::).
+
+ In order for the extension to tell `gawk' that it is properly
+licensed, the extension must define the global symbol
+`plugin_is_GPL_compatible'. If this symbol does not exist, `gawk'
+emits a fatal error and exits when it tries to load your extension.
The declared type of the symbol should be `int'. It does not need
to be in any allocated section, though. The code merely asserts that
@@ -22378,7 +22656,7 @@ File: gawk.info, Node: Extension Mechanism Outline, Next: Extension API Descri
=================================
Communication between `gawk' and an extension is two-way. First, when
-an extension is loaded, it is passed a pointer to a `struct' whose
+an extension is loaded, `gawk' passes it a pointer to a `struct' whose
fields are function pointers. This is shown in *note
figure-load-extension::.
@@ -22411,8 +22689,8 @@ Figure 16.1: Loading The Extension
The extension can call functions inside `gawk' through these
function pointers, at runtime, without needing (link-time) access to
`gawk''s symbols. One of these function pointers is to a function for
-"registering" new built-in functions. This is shown in *note
-figure-load-new-function::.
+"registering" new functions. This is shown in *note
+figure-register-new-function::.
register_ext_func({ "chdir", do_chdir, 1 });
@@ -22426,7 +22704,7 @@ figure-load-new-function::.
+-------+-+---+-+---+-+------------------+--------------+-+---+
gawk Main Program Address Space Extension
-Figure 16.2: Loading The New Function
+Figure 16.2: Registering A New Function
In the other direction, the extension registers its new functions
with `gawk' by passing function pointers to the functions that provide
@@ -22459,8 +22737,8 @@ and understandable.
Although all of this sounds somewhat complicated, the result is that
extension code is quite straightforward to write and to read. You can
-see this in the sample extensions `filefuncs.c' (*note Extension
-Example::) and also the `testext.c' code for testing the APIs.
+see this in the sample extension `filefuncs.c' (*note Extension
+Example::) and also in the `testext.c' code for testing the APIs.
Some other bits and pieces:
@@ -22491,13 +22769,13 @@ describes the API in detail.
* Extension API Functions Introduction:: Introduction to the API functions.
* General Data Types:: The data types.
-* Requesting Values:: How to get a value.
* Memory Allocation Functions:: Functions for allocating memory.
* Constructor Functions:: Functions for creating values.
* Registration Functions:: Functions to register things with
`gawk'.
* Printing Messages:: Functions for printing messages.
* Updating `ERRNO':: Functions for updating `ERRNO'.
+* Requesting Values:: How to get a value.
* Accessing Parameters:: Functions for accessing parameters.
* Symbol Table Access:: Functions for accessing global
variables.
@@ -22517,6 +22795,8 @@ through function pointers passed into your extension.
API function pointers are provided for the following kinds of
operations:
+ * Allocating, reallocating, and releasing memory.
+
* Registration functions. You may register:
- extension functions,
@@ -22541,8 +22821,6 @@ operations:
* Symbol table access: retrieving a global variable, creating one,
or changing one.
- * Allocating, reallocating, and releasing memory.
-
* Creating and releasing cached values; this provides an efficient
way to use values for multiple variables and can be a big
performance win.
@@ -22596,9 +22874,8 @@ operations:
* All pointers filled in by `gawk' point to memory managed by `gawk'
and should be treated by the extension as read-only. Memory for
_all_ strings passed into `gawk' from the extension _must_ come
- from calling the API-provided function pointers `api_malloc()',
- `api_calloc()' or `api_realloc()', and is managed by `gawk' from
- then on.
+ from calling one of `gawk_malloc()', `gawk_calloc()' or
+ `gawk_realloc()', and is managed by `gawk' from then on.
* The API defines several simple `struct's that map values as seen
from `awk'. A value can be a `double', a string, or an array (as
@@ -22614,7 +22891,7 @@ operations:
* When retrieving a value (such as a parameter or that of a global
variable or array element), the extension requests a specific type
- (number, string, scalars, value cookie, array, or "undefined").
+ (number, string, scalar, value cookie, array, or "undefined").
When the request is "undefined," the returned value will have the
real underlying type.
@@ -22631,7 +22908,7 @@ macros that you should use in your code. This minor node presents the
macros as if they were functions.

-File: gawk.info, Node: General Data Types, Next: Requesting Values, Prev: Extension API Functions Introduction, Up: Extension API Description
+File: gawk.info, Node: General Data Types, Next: Memory Allocation Functions, Prev: Extension API Functions Introduction, Up: Extension API Description
16.4.2 General Purpose Data Types
---------------------------------
@@ -22670,9 +22947,8 @@ that use them.
`} awk_string_t;'
This represents a mutable string. `gawk' owns the memory pointed
to if it supplied the value. Otherwise, it takes ownership of the
- memory pointed to. *Such memory must come from calling the
- API-provided function pointers `api_malloc()', `api_calloc()', or
- `api_realloc()'!*
+ memory pointed to. *Such memory must come from calling one of the
+ `gawk_malloc()', `gawk_calloc()', or `gawk_realloc()' functions!*
As mentioned earlier, strings are maintained using the current
multibyte encoding.
@@ -22758,7 +23034,7 @@ can obtain a "scalar cookie"(1) object for that variable, and then use
the cookie for getting the variable's value or for changing the
variable's value. This is the `awk_scalar_t' type and `scalar_cookie'
macro. Given a scalar cookie, `gawk' can directly retrieve or modify
-the value, as required, without having to first find it.
+the value, as required, without having to find it first.
The `awk_value_cookie_t' type and `value_cookie' macro are similar.
If you know that you wish to use the same numeric or string _value_ for
@@ -22777,62 +23053,30 @@ the value.
See also the entry for "Cookie" in the *note Glossary::.

-File: gawk.info, Node: Requesting Values, Next: Memory Allocation Functions, Prev: General Data Types, Up: Extension API Description
-
-16.4.3 Requesting Values
-------------------------
+File: gawk.info, Node: Memory Allocation Functions, Next: Constructor Functions, Prev: General Data Types, Up: Extension API Description
-All of the functions that return values from `gawk' work in the same
-way. You pass in an `awk_valtype_t' value to indicate what kind of
-value you expect. If the actual value matches what you requested, the
-function returns true and fills in the `awk_value_t' result.
-Otherwise, the function returns false, and the `val_type' member
-indicates the type of the actual value. You may then print an error
-message, or reissue the request for the actual value type, as
-appropriate. This behavior is summarized in *note
-table-value-types-returned::.
-
- Type of Actual Value:
---------------------------------------------------------------------------
-
- String Number Array Undefined
-------------------------------------------------------------------------------
- String String String false false
- Number Number if can Number false false
- be converted,
- else false
-Type Array false false Array false
-Requested: Scalar Scalar Scalar false false
- Undefined String Number Array Undefined
- Value false false false false
- Cookie
-
-Table 16.1: API Value Types Returned
-
-
-File: gawk.info, Node: Memory Allocation Functions, Next: Constructor Functions, Prev: Requesting Values, Up: Extension API Description
-
-16.4.4 Memory Allocation Functions and Convenience Macros
+16.4.3 Memory Allocation Functions and Convenience Macros
---------------------------------------------------------
The API provides a number of "memory allocation" functions for
allocating memory that can be passed to `gawk', as well as a number of
-convenience macros.
+convenience macros. This node presents them all as function
+prototypes, in the way that extension code would use them.
`void *gawk_malloc(size_t size);'
- Call `gawk'-provided `api_malloc()' to allocate storage that may
+ Call the correct version of `malloc()' to allocate storage that may
be passed to `gawk'.
`void *gawk_calloc(size_t nmemb, size_t size);'
- Call `gawk'-provided `api_calloc()' to allocate storage that may
+ Call the correct version of `calloc()' to allocate storage that may
be passed to `gawk'.
`void *gawk_realloc(void *ptr, size_t size);'
- Call `gawk'-provided `api_realloc()' to allocate storage that may
- be passed to `gawk'.
+ Call the correct version of `realloc()' to allocate storage that
+ may be passed to `gawk'.
`void gawk_free(void *ptr);'
- Call `gawk'-provided `api_free()' to release storage that was
+ Call the correct version of `free()' to release storage that was
allocated with `gawk_malloc()', `gawk_calloc()' or
`gawk_realloc()'.
@@ -22842,11 +23086,10 @@ C library than was used for the `gawk' executable.(1) If `gawk' were to
use its version of `free()' when the memory came from an unrelated
version of `malloc()', unexpected behavior would likely result.
- Two convenience macros may be used for allocating storage from the
-API-provided function pointers `api_malloc()' and `api_realloc()'. If
-the allocation fails, they cause `gawk' to exit with a fatal error
-message. They should be used as if they were procedure calls that do
-not return a value.
+ Two convenience macros may be used for allocating storage from
+`gawk_malloc()' and `gawk_realloc()'. If the allocation fails, they
+cause `gawk' to exit with a fatal error message. They should be used
+as if they were procedure calls that do not return a value.
`#define emalloc(pointer, type, size, message) ...'
The arguments to this macro are as follows:
@@ -22856,7 +23099,7 @@ not return a value.
`type'
The type of the pointer variable, used to create a cast for
- the call to `api_malloc()'.
+ the call to `gawk_malloc()'.
`size'
The total number of bytes to be allocated.
@@ -22876,9 +23119,9 @@ not return a value.
make_malloced_string(message, strlen(message), & result);
`#define erealloc(pointer, type, size, message) ...'
- This is like `emalloc()', but it calls `api_realloc()', instead of
- `api_malloc()'. The arguments are the same as for the `emalloc()'
- macro.
+ This is like `emalloc()', but it calls `gawk_realloc()', instead
+ of `gawk_malloc()'. The arguments are the same as for the
+ `emalloc()' macro.
---------- Footnotes ----------
@@ -22888,7 +23131,7 @@ Unix-like systems as well.

File: gawk.info, Node: Constructor Functions, Next: Registration Functions, Prev: Memory Allocation Functions, Up: Extension API Description
-16.4.5 Constructor Functions
+16.4.4 Constructor Functions
----------------------------
The API provides a number of "constructor" functions for creating
@@ -22907,10 +23150,10 @@ extension code would use them.
`make_malloced_string(const char *string, size_t length, awk_value_t *result)'
This function creates a string value in the `awk_value_t' variable
pointed to by `result'. It expects `string' to be a `char *' value
- pointing to data previously obtained from the api-provided
- functions `api_malloc()', `api_calloc()' or `api_realloc()'. The
- idea here is that the data is passed directly to `gawk', which
- assumes responsibility for it. It returns `result'.
+ pointing to data previously obtained from `gawk_malloc()',
+ `gawk_calloc()' or `gawk_realloc()'. The idea here is that the
+ data is passed directly to `gawk', which assumes responsibility
+ for it. It returns `result'.
`static inline awk_value_t *'
`make_null_string(awk_value_t *result)'
@@ -22926,7 +23169,7 @@ extension code would use them.

File: gawk.info, Node: Registration Functions, Next: Printing Messages, Prev: Constructor Functions, Up: Extension API Description
-16.4.6 Registration Functions
+16.4.5 Registration Functions
-----------------------------
This minor node describes the API functions for registering parts of
@@ -22944,7 +23187,7 @@ your extension with `gawk'.

File: gawk.info, Node: Extension Functions, Next: Exit Callback Functions, Up: Registration Functions
-16.4.6.1 Registering An Extension Function
+16.4.5.1 Registering An Extension Function
..........................................
Extension functions are described by the following record:
@@ -22962,17 +23205,16 @@ Extension functions are described by the following record:
by this name. This is a regular C string.
Function names must obey the rules for `awk' identifiers. That is,
- they must begin with either a letter or an underscore, which may
- be followed by any number of letters, digits, and underscores.
- Letter case in function names is significant.
+ they must begin with either an English letter or an underscore,
+ which may be followed by any number of letters, digits, and
+ underscores. Letter case in function names is significant.
`awk_value_t *(*function)(int num_actual_args, awk_value_t *result);'
- This is a pointer to the C function that provides the desired
- functionality. The function must fill in the result with either a
+ This is a pointer to the C function that provides the extension's
+ functionality. The function must fill in `*result' with either a
number or a string. `gawk' takes ownership of any string memory.
- As mentioned earlier, string memory *must* come from the
- api-provided functions `api_malloc()', `api_calloc()' or
- `api_realloc()'.
+ As mentioned earlier, string memory *must* come from one of
+ `gawk_malloc()', `gawk_calloc()' or `gawk_realloc()'.
The `num_actual_args' argument tells the C function how many
actual parameters were passed from the calling `awk' code.
@@ -22983,7 +23225,7 @@ Extension functions are described by the following record:
`size_t num_expected_args;'
This is the number of arguments the function expects to receive.
Each extension function may decide what to do if the number of
- arguments isn't what it expected. Following `awk' functions, it
+ arguments isn't what it expected. As with real `awk' functions, it
is likely OK to ignore extra arguments.
Once you have a record representing your extension function, you
@@ -22998,7 +23240,7 @@ register it with `gawk' using this API function:

File: gawk.info, Node: Exit Callback Functions, Next: Extension Version String, Prev: Extension Functions, Up: Registration Functions
-16.4.6.2 Registering An Exit Callback Function
+16.4.5.2 Registering An Exit Callback Function
..............................................
An "exit callback" function is a function that `gawk' calls before it
@@ -23028,7 +23270,7 @@ order--that is, in the reverse order in which they are registered with

File: gawk.info, Node: Extension Version String, Next: Input Parsers, Prev: Exit Callback Functions, Up: Registration Functions
-16.4.6.3 Registering An Extension Version String
+16.4.5.3 Registering An Extension Version String
................................................
You can register a version string which indicates the name and version
@@ -23044,7 +23286,7 @@ invoked with the `--version' option.

File: gawk.info, Node: Input Parsers, Next: Output Wrappers, Prev: Extension Version String, Up: Registration Functions
-16.4.6.4 Customized Input Parsers
+16.4.5.4 Customized Input Parsers
.................................
By default, `gawk' reads text files as its input. It uses the value of
@@ -23213,7 +23455,7 @@ records. The parameters are as follows:
`*rt_start' should be set to point to the data to be used for
`RT', and `*rt_len' should be set to the length of the data.
Otherwise, `*rt_len' should be set to zero. `gawk' makes its own
- copy of this data, so the extension must manage the storage.
+ copy of this data, so the extension must manage this storage.
The return value is the length of the buffer pointed to by `*out',
or `EOF' if end-of-file was reached or an error occurred.
@@ -23267,7 +23509,7 @@ whether or not to activate an input parser (*note BEGINFILE/ENDFILE::).

File: gawk.info, Node: Output Wrappers, Next: Two-way processors, Prev: Input Parsers, Up: Registration Functions
-16.4.6.5 Customized Output Wrappers
+16.4.5.5 Customized Output Wrappers
...................................
An "output wrapper" is the mirror image of an input parser. It allows
@@ -23374,7 +23616,7 @@ just use normally.

File: gawk.info, Node: Two-way processors, Prev: Output Wrappers, Up: Registration Functions
-16.4.6.6 Customized Two-way Processors
+16.4.5.6 Customized Two-way Processors
......................................
A "two-way processor" combines an input parser and an output wrapper for
@@ -23427,7 +23669,7 @@ can take this" and "take over for this" functions,

File: gawk.info, Node: Printing Messages, Next: Updating `ERRNO', Prev: Registration Functions, Up: Extension API Description
-16.4.7 Printing Messages
+16.4.6 Printing Messages
------------------------
You can print different kinds of warning messages from your extension,
@@ -23456,9 +23698,9 @@ of the ISO C 99 variadic macro feature to hide that parameter. More's
the pity.

-File: gawk.info, Node: Updating `ERRNO', Next: Accessing Parameters, Prev: Printing Messages, Up: Extension API Description
+File: gawk.info, Node: Updating `ERRNO', Next: Requesting Values, Prev: Printing Messages, Up: Extension API Description
-16.4.8 Updating `ERRNO'
+16.4.7 Updating `ERRNO'
-----------------------
The following functions allow you to update the `ERRNO' variable:
@@ -23473,11 +23715,44 @@ The following functions allow you to update the `ERRNO' variable:
Set `ERRNO' directly to the string value of `ERRNO'. `gawk' makes
a copy of the value of `string'.
-`void unset_ERRNO();'
+`void unset_ERRNO(void);'
Unset `ERRNO'.

-File: gawk.info, Node: Accessing Parameters, Next: Symbol Table Access, Prev: Updating `ERRNO', Up: Extension API Description
+File: gawk.info, Node: Requesting Values, Next: Accessing Parameters, Prev: Updating `ERRNO', Up: Extension API Description
+
+16.4.8 Requesting Values
+------------------------
+
+All of the functions that return values from `gawk' work in the same
+way. You pass in an `awk_valtype_t' value to indicate what kind of
+value you expect. If the actual value matches what you requested, the
+function returns true and fills in the `awk_value_t' result.
+Otherwise, the function returns false, and the `val_type' member
+indicates the type of the actual value. You may then print an error
+message, or reissue the request for the actual value type, as
+appropriate. This behavior is summarized in *note
+table-value-types-returned::.
+
+ Type of Actual Value:
+--------------------------------------------------------------------------
+
+ String Number Array Undefined
+------------------------------------------------------------------------------
+ String String String false false
+ Number Number if can Number false false
+ be converted,
+ else false
+Type Array false false Array false
+Requested: Scalar Scalar Scalar false false
+ Undefined String Number Array Undefined
+ Value false false false false
+ Cookie
+
+Table 16.1: API Value Types Returned
+
+
+File: gawk.info, Node: Accessing Parameters, Next: Symbol Table Access, Prev: Requesting Values, Up: Extension API Description
16.4.9 Accessing and Updating Parameters
----------------------------------------
@@ -23535,7 +23810,7 @@ termed a "symbol table".
Fill in the `awk_value_t' structure pointed to by `result' with
the value of the variable named by the string `name', which is a
regular C string. `wanted' indicates the type of value expected.
- Return true if the actual type matches `wanted', false otherwise
+ Return true if the actual type matches `wanted', false otherwise.
In the latter case, `result->val_type' indicates the actual type
(*note Table 16.1: table-value-types-returned.).
@@ -23553,7 +23828,7 @@ termed a "symbol table".
However, with the exception of the `PROCINFO' array, an extension
cannot change any of those variables.
- NOTE: It is possible for the lookup of `PROCINFO' to fail. This
+ CAUTION: It is possible for the lookup of `PROCINFO' to fail. This
happens if the `awk' program being run does not reference
`PROCINFO'; in this case `gawk' doesn't bother to create the array
and populate it.
@@ -23575,14 +23850,14 @@ was discussed earlier, in *note General Data Types::.
` awk_valtype_t wanted,'
` awk_value_t *result);'
Retrieve the current value of a scalar cookie. Once you have
- obtained a scalar_cookie using `sym_lookup()', you can use this
+ obtained a scalar cookie using `sym_lookup()', you can use this
function to get its value more efficiently. Return false if the
value cannot be retrieved.
`awk_bool_t sym_update_scalar(awk_scalar_t cookie, awk_value_t *value);'
Update the value associated with a scalar cookie. Return false if
the new value is not of type `AWK_STRING' or `AWK_NUMBER'. Here
- too, the built-in variables may not be updated.
+ too, the predefined variables may not be updated.
It is not obvious at first glance how to work with scalar cookies or
what their raison d'e^tre really is. In theory, the `sym_lookup()' and
@@ -23634,7 +23909,7 @@ usual. Then get a scalar cookie for the variable using `sym_lookup()':
/* install initial value */
sym_update("MAGIC_VAR", make_number(42.0, & value));
- /* get cookie */
+ /* get the cookie */
sym_lookup("MAGIC_VAR", AWK_SCALAR, & value);
/* save the cookie */
@@ -23685,7 +23960,7 @@ variables using `sym_update()' or `sym_update_scalar()', as you like.
However, you can understand the point of cached values if you
remember that _every_ string value's storage _must_ come from
-`api_malloc()', `api_calloc()' or `api_realloc()'. If you have 20
+`gawk_malloc()', `gawk_calloc()' or `gawk_realloc()'. If you have 20
variables, all of which have the same string value, you must create 20
identical copies of the string.(1)
@@ -23749,8 +24024,8 @@ Using value cookies in this way saves considerable storage, since all of
`VAR1' through `VAR100' share the same value.
You might be wondering, "Is this sharing problematic? What happens
-if `awk' code assigns a new value to `VAR1', are all the others be
-changed too?"
+if `awk' code assigns a new value to `VAR1', are all the others changed
+too?"
That's a great question. The answer is that no, it's not a problem.
Internally, `gawk' uses "reference-counted strings". This means that
@@ -23816,7 +24091,7 @@ The data types associated with arrays are listed below.
` struct awk_element *next;'
` enum {'
` AWK_ELEMENT_DEFAULT = 0, /* set by gawk */'
-` AWK_ELEMENT_DELETE = 1 /* set by extension if should be deleted */'
+` AWK_ELEMENT_DELETE = 1 /* set by extension */'
` } flags;'
` awk_value_t index;'
` awk_value_t value;'
@@ -23834,8 +24109,8 @@ The data types associated with arrays are listed below.
the list.
`enum { ... } flags;'
- A set of flag values that convey information between `gawk'
- and the extension. Currently there is only one:
+ A set of flag values that convey information between the
+ extension and `gawk'. Currently there is only one:
`AWK_ELEMENT_DELETE'. Setting it causes `gawk' to delete the
element from the original array upon release of the flattened
array.
@@ -23846,8 +24121,8 @@ The data types associated with arrays are listed below.
memory pointed to by `index' and `value' belongs to `gawk'.
`typedef struct awk_flat_array {'
-` awk_const void *awk_const opaque1; /* private data for use by gawk */'
-` awk_const void *awk_const opaque2; /* private data for use by gawk */'
+` awk_const void *awk_const opaque1; /* for use by gawk */'
+` awk_const void *awk_const opaque2; /* for use by gawk */'
` awk_const size_t count; /* how many elements */'
` awk_element_t elements[1]; /* will be extended */'
`} awk_flat_array_t;'
@@ -23871,7 +24146,7 @@ File: gawk.info, Node: Array Functions, Next: Flattening Arrays, Prev: Array
The following functions relate to individual array elements.
`awk_bool_t get_element_count(awk_array_t a_cookie, size_t *count);'
- For the array represented by `a_cookie', return in `*count' the
+ For the array represented by `a_cookie', place in `*count' the
number of elements it contains. A subarray counts as a single
element. Return false if there is an error.
@@ -23891,9 +24166,9 @@ The following functions relate to individual array elements.
strings (*note Conversion::); thus using integral values is safest.
As with _all_ strings passed into `gawk' from an extension, the
- string value of `index' must come from the API-provided functions
- `api_malloc()', `api_calloc()' or `api_realloc()' and `gawk'
- releases the storage.
+ string value of `index' must come from `gawk_malloc()',
+ `gawk_calloc()' or `gawk_realloc()', and `gawk' releases the
+ storage.
`awk_bool_t set_array_element(awk_array_t a_cookie,'
` const awk_value_t *const index,'
@@ -23915,7 +24190,7 @@ The following functions relate to individual array elements.
The following functions relate to arrays as a whole:
-`awk_array_t create_array();'
+`awk_array_t create_array(void);'
Create a new array to which elements may be added. *Note Creating
Arrays::, for a discussion of how to create a new array and add
elements to it.
@@ -23951,7 +24226,8 @@ array in a fashion that makes it easy for C code to traverse the entire
array. Test code in `extension/testext.c' does this, and also serves
as a nice example showing how to use the APIs.
- First, the `gawk' script that drives the test extension:
+ We walk through that part of the code one step at a time. First,
+the `gawk' script that drives the test extension:
@load "testext"
BEGIN {
@@ -24072,8 +24348,7 @@ flag bit set:
valrep2str(& flat_array->elements[i].value));
if (strcmp(value3.str_value.str,
- flat_array->elements[i].index.str_value.str)
- == 0) {
+ flat_array->elements[i].index.str_value.str) == 0) {
flat_array->elements[i].flags |= AWK_ELEMENT_DELETE;
printf("dump_array_and_delete: marking element \"%s\" "
"for deletion\n",
@@ -24163,9 +24438,9 @@ code:
The following C code is a simple test extension to create an array
with two regular elements and with a subarray. The leading `#include'
-directives and boilerplate variable declarations are omitted for
-brevity. The first step is to create a new array and then install it
-in the symbol table:
+directives and boilerplate variable declarations (*note Extension API
+Boilerplate::) are omitted for brevity. The first step is to create a
+new array and then install it in the symbol table:
/* create_new_array --- create a named array */
@@ -24352,8 +24627,8 @@ invoked. The variables are:
option.
The value of `do_lint' can change if `awk' code modifies the `LINT'
-built-in variable (*note Built-in Variables::). The others should not
-change during execution.
+predefined variable (*note Built-in Variables::). The others should
+not change during execution.

File: gawk.info, Node: Extension API Boilerplate, Prev: Extension API Variables, Up: Extension API Description
@@ -24387,12 +24662,12 @@ in the `gawkapi.h' header file:
/* OR: */
static awk_bool_t
- init_my_module(void)
+ init_my_extension(void)
{
...
}
- static awk_bool_t (*init_func)(void) = init_my_module;
+ static awk_bool_t (*init_func)(void) = init_my_extension;
dl_load_func(func_table, some_name, "name_space_in_quotes")
@@ -24424,8 +24699,8 @@ in the `gawkapi.h' header file:
`static awk_bool_t (*init_func)(void) = NULL;'
` OR'
-`static awk_bool_t init_my_module(void) { ... }'
-`static awk_bool_t (*init_func)(void) = init_my_module;'
+`static awk_bool_t init_my_extension(void) { ... }'
+`static awk_bool_t (*init_func)(void) = init_my_extension;'
If you need to do some initialization work, you should define a
function that does it (creates variables, opens files, etc.) and
then define the `init_func' pointer to point to your function.
@@ -24479,8 +24754,9 @@ File: gawk.info, Node: Extension Example, Next: Extension Samples, Prev: Find
Two useful functions that are not in `awk' are `chdir()' (so that an
`awk' program can change its directory) and `stat()' (so that an `awk'
-program can gather information about a file). This minor node
-implements these functions for `gawk' in an extension.
+program can gather information about a file). In order to illustrate
+the API in action, this minor node implements these functions for
+`gawk' in an extension.
* Menu:
@@ -24504,8 +24780,7 @@ directory to change to:
newdir = "/home/arnold/funstuff"
ret = chdir(newdir)
if (ret < 0) {
- printf("could not change to %s: %s\n",
- newdir, ERRNO) > "/dev/stderr"
+ printf("could not change to %s: %s\n", newdir, ERRNO) > "/dev/stderr"
exit 1
}
...
@@ -24670,7 +24945,7 @@ arguments: the first is an `int' usually called `nargs', that
represents the number of actual arguments for the function. The second
is a pointer to an `awk_value_t', usually named `result'.
- /* do_chdir --- provide dynamically loaded chdir() builtin for gawk */
+ /* do_chdir --- provide dynamically loaded chdir() function for gawk */
static awk_value_t *
do_chdir(int nargs, awk_value_t *result)
@@ -24858,12 +25133,20 @@ and/or the type of the file. It then returns zero, for success:
}
}
- array_set(array, "type", make_const_string(type, strlen(type), &tmp));
+ array_set(array, "type", make_const_string(type, strlen(type), & tmp));
return 0;
}
- Finally, here is the `do_stat()' function. It starts with variable
+ The third argument to `stat()' was not discussed previously. This
+argument is optional. If present, it causes `do_stat()' to use the
+`stat()' system call instead of the `lstat()' system call. This is
+done by using a function pointer: `statfunc'. `statfunc' is
+initialized to point to `lstat()' (instead of `stat()') to get the file
+information, in case the file is a symbolic link. However, if there
+were three arguments, `statfunc' is set point to `stat()', instead.
+
+ Here is the `do_stat()' function. It starts with variable
declarations and argument checking:
/* do_stat --- provide a stat() function for gawk */
@@ -24888,14 +25171,10 @@ declarations and argument checking:
return make_number(-1, result);
}
- The third argument to `stat()' was not discussed previously. This
-argument is optional. If present, it causes `stat()' to use the `stat()'
-system call instead of the `lstat()' system call.
-
Then comes the actual work. First, the function gets the arguments.
-Next, it gets the information for the file. The code use `lstat()'
-(instead of `stat()') to get the file information, in case the file is
-a symbolic link. If there's an error, it sets `ERRNO' and returns:
+Next, it gets the information for the file. If the called function
+(`lstat()' or `stat()') returns an error, the code sets `ERRNO' and
+returns:
/* file is first arg, array to hold results is second */
if ( ! get_argument(0, AWK_STRING, & file_param)
@@ -24922,7 +25201,7 @@ a symbolic link. If there's an error, it sets `ERRNO' and returns:
}
The tedious work is done by `fill_stat_array()', shown earlier.
-When done, return the result from `fill_stat_array()':
+When done, the function returns the result from `fill_stat_array()':
ret = fill_stat_array(name, array, & sbuf);
@@ -25004,14 +25283,14 @@ create a GNU/Linux shared library:
for (i in data)
printf "data[\"%s\"] = %s\n", i, data[i]
print "testff.awk modified:",
- strftime("%m %d %y %H:%M:%S", data["mtime"])
+ strftime("%m %d %Y %H:%M:%S", data["mtime"])
print "\nInfo for JUNK"
ret = stat("JUNK", data)
print "ret =", ret
for (i in data)
printf "data[\"%s\"] = %s\n", i, data[i]
- print "JUNK modified:", strftime("%m %d %y %H:%M:%S", data["mtime"])
+ print "JUNK modified:", strftime("%m %d %Y %H:%M:%S", data["mtime"])
}
The `AWKLIBPATH' environment variable tells `gawk' where to find
@@ -25023,32 +25302,33 @@ directory and run the program:
-| Info for testff.awk
-| ret = 0
-| data["blksize"] = 4096
- -| data["mtime"] = 1350838628
+ -| data["devbsize"] = 512
+ -| data["mtime"] = 1412004710
-| data["mode"] = 33204
-| data["type"] = file
-| data["dev"] = 2053
-| data["gid"] = 1000
- -| data["ino"] = 1719496
- -| data["ctime"] = 1350838628
+ -| data["ino"] = 10358899
+ -| data["ctime"] = 1412004710
-| data["blocks"] = 8
-| data["nlink"] = 1
-| data["name"] = testff.awk
- -| data["atime"] = 1350838632
+ -| data["atime"] = 1412004716
-| data["pmode"] = -rw-rw-r--
- -| data["size"] = 662
+ -| data["size"] = 666
-| data["uid"] = 1000
- -| testff.awk modified: 10 21 12 18:57:08
+ -| testff.awk modified: 09 29 2014 18:31:50
-|
-| Info for JUNK
-| ret = -1
- -| JUNK modified: 01 01 70 02:00:00
+ -| JUNK modified: 01 01 1970 02:00:00
---------- Footnotes ----------
(1) In practice, you would probably want to use the GNU
Autotools--Automake, Autoconf, Libtool, and `gettext'--to configure and
build your libraries. Instructions for doing so are beyond the scope of
-this Info file. *Note gawkextlib::, for WWW links to the tools.
+this Info file. *Note gawkextlib::, for Internet links to the tools.

File: gawk.info, Node: Extension Samples, Next: gawkextlib, Prev: Extension Example, Up: Dynamic Extensions
@@ -25076,9 +25356,9 @@ the extension API.
* Extension Sample Rev2way:: Reversing data sample two-way processor.
* Extension Sample Read write array:: Serializing an array to a file.
* Extension Sample Readfile:: Reading an entire file into a string.
-* Extension Sample API Tests:: Tests for the API.
* Extension Sample Time:: An interface to `gettimeofday()'
and `sleep()'.
+* Extension Sample API Tests:: Tests for the API.

File: gawk.info, Node: Extension Sample File Functions, Next: Extension Sample Fnmatch, Up: Extension Samples
@@ -25089,7 +25369,7 @@ File: gawk.info, Node: Extension Sample File Functions, Next: Extension Sample
The `filefuncs' extension provides three different functions, as
follows: The usage is:
-@load "filefuncs"
+`@load "filefuncs"'
This is how you load the extension.
`result = chdir("/some/directory")'
@@ -25145,8 +25425,8 @@ follows: The usage is:
`result = fts(pathlist, flags, filedata)'
Walk the file trees provided in `pathlist' and fill in the
`filedata' array as described below. `flags' is the bitwise OR of
- several predefined constant values, also described below. Return
- zero if there were no errors, otherwise return -1.
+ several predefined values, also described below. Return zero if
+ there were no errors, otherwise return -1.
The `fts()' function provides a hook to the C library `fts()'
routines for traversing file hierarchies. Instead of returning data
@@ -25187,10 +25467,10 @@ requested hierarchies.
whether or not `FTS_LOGICAL' is set.
`FTS_SEEDOT'
- By default, the `fts()' routines do not return entries for
- `.' (dot) and `..' (dot-dot). This option causes entries for
- dot-dot to also be included. (The extension always includes
- an entry for dot, see below.)
+ By default, the C library `fts()' routines do not return
+ entries for `.' (dot) and `..' (dot-dot). This option causes
+ entries for dot-dot to also be included. (The extension
+ always includes an entry for dot, see below.)
`FTS_XDEV'
During a traversal, do not cross onto a different mounted
@@ -25240,15 +25520,16 @@ Otherwise it returns -1.
NOTE: The `fts()' extension does not exactly mimic the interface
of the C library `fts()' routines, choosing instead to provide an
- interface that is based on associative arrays, which should be
- more comfortable to use from an `awk' program. This includes the
- lack of a comparison function, since `gawk' already provides
- powerful array sorting facilities. While an `fts_read()'-like
- interface could have been provided, this felt less natural than
- simply creating a multidimensional array to represent the file
- hierarchy and its information.
+ interface that is based on associative arrays, which is more
+ comfortable to use from an `awk' program. This includes the lack
+ of a comparison function, since `gawk' already provides powerful
+ array sorting facilities. While an `fts_read()'-like interface
+ could have been provided, this felt less natural than simply
+ creating a multidimensional array to represent the file hierarchy
+ and its information.
- See `test/fts.awk' in the `gawk' distribution for an example.
+ See `test/fts.awk' in the `gawk' distribution for an example use of
+the `fts()' extension function.

File: gawk.info, Node: Extension Sample Fnmatch, Next: Extension Sample Fork, Prev: Extension Sample File Functions, Up: Extension Samples
@@ -25443,7 +25724,7 @@ Letter File Type
`s' Socket
`u' Anything else (unknown)
-Table 16.2: File Types Returned By `readdir()'
+Table 16.2: File Types Returned By The `readdir' Extension
On systems without the file type information, the third field is
always `u'.
@@ -25514,6 +25795,9 @@ File: gawk.info, Node: Extension Sample Read write array, Next: Extension Samp
The `rwarray' extension adds two functions, named `writea()' and
`reada()', as follows:
+`@load "rwarray"'
+ This is how you load the extension.
+
`ret = writea(file, array)'
This function takes a string argument, which is the name of the
file to which to dump the array, and the array itself as the
@@ -25550,7 +25834,7 @@ restored on systems with a different one, but this has not been tried.
ret = reada("arraydump.bin", array)

-File: gawk.info, Node: Extension Sample Readfile, Next: Extension Sample API Tests, Prev: Extension Sample Read write array, Up: Extension Samples
+File: gawk.info, Node: Extension Sample Readfile, Next: Extension Sample Time, Prev: Extension Sample Read write array, Up: Extension Samples
16.7.10 Reading An Entire File
------------------------------
@@ -25583,21 +25867,9 @@ an input parser:
}

-File: gawk.info, Node: Extension Sample API Tests, Next: Extension Sample Time, Prev: Extension Sample Readfile, Up: Extension Samples
-
-16.7.11 API Tests
------------------
-
-The `testext' extension exercises parts of the extension API that are
-not tested by the other samples. The `extension/testext.c' file
-contains both the C code for the extension and `awk' test code inside C
-comments that run the tests. The testing framework extracts the `awk'
-code and runs the tests. See the source file for more information.
-
-
-File: gawk.info, Node: Extension Sample Time, Prev: Extension Sample API Tests, Up: Extension Samples
+File: gawk.info, Node: Extension Sample Time, Next: Extension Sample API Tests, Prev: Extension Sample Readfile, Up: Extension Samples
-16.7.12 Extension Time Functions
+16.7.11 Extension Time Functions
--------------------------------
The `time' extension adds two functions, named `gettimeofday()' and
@@ -25626,6 +25898,18 @@ The `time' extension adds two functions, named `gettimeofday()' and
delay.

+File: gawk.info, Node: Extension Sample API Tests, Prev: Extension Sample Time, Up: Extension Samples
+
+16.7.12 API Tests
+-----------------
+
+The `testext' extension exercises parts of the extension API that are
+not tested by the other samples. The `extension/testext.c' file
+contains both the C code for the extension and `awk' test code inside C
+comments that run the tests. The testing framework extracts the `awk'
+code and runs the tests. See the source file for more information.
+
+
File: gawk.info, Node: gawkextlib, Next: Extension summary, Prev: Extension Samples, Up: Dynamic Extensions
16.8 The `gawkextlib' Project
@@ -25638,21 +25922,17 @@ project.
As of this writing, there are five extensions:
- * XML parser extension, using the Expat
- (http://expat.sourceforge.net) XML parsing library.
+ * GD graphics library extension.
* PDF extension.
* PostgreSQL extension.
- * GD graphics library extension.
-
* MPFR library extension. This provides access to a number of MPFR
functions which `gawk''s native MPFR support does not.
- The `time' extension described earlier (*note Extension Sample
-Time::) was originally from this project but has been moved in to the
-main `gawk' distribution.
+ * XML parser extension, using the Expat
+ (http://expat.sourceforge.net) XML parsing library.
You can check out the code for the `gawkextlib' project using the
Git (http://git-scm.com) distributed source code control system. The
@@ -25716,7 +25996,7 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga
tasks.
* One of these tasks is to "register" the name and implementation of
- a new `awk'-level function with `gawk'. The implementation takes
+ new `awk'-level functions with `gawk'. The implementation takes
the form of a C function pointer with a defined signature. By
convention, implementation functions are named `do_XXXX()' for
some `awk'-level function `XXXX()'.
@@ -25728,6 +26008,8 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga
* API function pointers are provided for the following kinds of
operations:
+ * Allocating, reallocating, and releasing memory.
+
* Registration functions. You may register extension functions,
exit callbacks, a version string, input parsers, output
wrappers, and two-way processors.
@@ -25742,8 +26024,6 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga
* Symbol table access: retrieving a global variable, creating
one, or changing one.
- * Allocating, reallocating, and releasing memory.
-
* Creating and releasing cached values; this provides an
efficient way to use values for multiple variables and can be
a big performance win.
@@ -25752,7 +26032,7 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga
modifying elements; getting the count of elements in an array;
creating a new array; clearing an array; and flattening an
array for easy C style looping over all its indices and
- elements
+ elements.
* The API defines a number of standard data types for representing
`awk' values, array elements, and arrays.
@@ -25767,7 +26047,7 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga
* _All_ memory passed from an extension to `gawk' must come from the
API's memory allocation functions. `gawk' takes responsibility for
- the memory and will release it when appropriate.
+ the memory and releases it when appropriate.
* The API provides information about the running version of `gawk' so
that an extension can make sure it is compatible with the `gawk'
@@ -25781,7 +26061,7 @@ File: gawk.info, Node: Extension summary, Next: Extension Exercises, Prev: ga
sample extensions. The `gawkextlib' project includes several more,
larger, extensions. If you wish to write an extension and
contribute it to the community of `gawk' users, the `gawkextlib'
- project should be the place to do so.
+ project is the place to do so.

@@ -25814,11 +26094,11 @@ This Info file describes the GNU implementation of `awk', which follows
the POSIX specification. Many long-time `awk' users learned `awk'
programming with the original `awk' implementation in Version 7 Unix.
(This implementation was the basis for `awk' in Berkeley Unix, through
-4.3-Reno. Subsequent versions of Berkeley Unix, and some systems
-derived from 4.4BSD-Lite, used various versions of `gawk' for their
-`awk'.) This major node briefly describes the evolution of the `awk'
-language, with cross-references to other parts of the Info file where
-you can find more information.
+4.3-Reno. Subsequent versions of Berkeley Unix, and, for a while, some
+systems derived from 4.4BSD-Lite, used various versions of `gawk' for
+their `awk'.) This major node briefly describes the evolution of the
+`awk' language, with cross-references to other parts of the Info file
+where you can find more information.
* Menu:
@@ -25868,7 +26148,7 @@ the changes, with cross-references to further details:
Functions::).
* The `ARGC', `ARGV', `FNR', `RLENGTH', `RSTART', and `SUBSEP'
- built-in variables (*note Built-in Variables::).
+ predefined variables (*note Built-in Variables::).
* Assignable `$0' (*note Changing Fields::).
@@ -25889,12 +26169,10 @@ the changes, with cross-references to further details:
Functions::), rather than using only the first character of `FS'.
* Dynamic regexps as operands of the `~' and `!~' operators (*note
- Regexp Usage::).
+ Computed Regexps::).
* The escape sequences `\b', `\f', and `\r' (*note Escape
- Sequences::). (Some vendors have updated their old versions of
- `awk' to recognize `\b', `\f', and `\r', but this is not something
- you can rely on.)
+ Sequences::).
* Redirection of input for the `getline' function (*note Getline::).
@@ -25918,7 +26196,7 @@ The System V Release 4 (1989) version of Unix `awk' added these features
* The `-v' option for assigning variables before program execution
begins (*note Options::).
- * The `--' option for terminating command-line options.
+ * The `--' signal for terminating command-line options.
* The `\a', `\v', and `\x' escape sequences (*note Escape
Sequences::).
@@ -25933,8 +26211,8 @@ The System V Release 4 (1989) version of Unix `awk' added these features
`printf' function (*note Control Letters::).
* The ability to dynamically pass the field width and precision
- (`"%*.*d"') in the argument list of the `printf' function (*note
- Control Letters::).
+ (`"%*.*d"') in the argument list of `printf' and `sprintf()'
+ (*note Control Letters::).
* The use of regexp constants, such as `/foo/', as expressions, where
they are equivalent to using the matching operator, as in `$0 ~
@@ -25961,8 +26239,8 @@ introduced the following changes into the language:
* The concept of a numeric string and tighter comparison rules to go
with it (*note Typing and Comparison::).
- * The use of built-in variables as function parameter names is
- forbidden (*note Definition Syntax::.
+ * The use of predefined variables as function parameter names is
+ forbidden (*note Definition Syntax::).
* More complete documentation of many of the previously undocumented
features of the language.
@@ -26024,7 +26302,7 @@ can all be disabled with either the `--traditional' or `--posix' options
node summarizes the additional features over POSIX `awk' that are in
the current version of `gawk'.
- * Additional built-in variables:
+ * Additional predefined variables:
- The `ARGIND' `BINMODE', `ERRNO', `FIELDWIDTHS', `FPAT',
`IGNORECASE', `LINT', `PROCINFO', `RT', and `TEXTDOMAIN'
@@ -26066,11 +26344,6 @@ the current version of `gawk'.
- The `BEGINFILE' and `ENDFILE' special patterns. (*note
BEGINFILE/ENDFILE::).
- - The ability to delete all of an array at once with `delete
- ARRAY' (*note Delete::).
-
- - The `nextfile' statement (*note Nextfile Statement::).
-
- The `switch' statement (*note Switch Statement::).
* Changes to standard `awk' functions:
@@ -26079,7 +26352,7 @@ the current version of `gawk'.
one end of a two-way pipe to a coprocess (*note Two-way
I/O::).
- - POSIX compliance for `gsub()' and `sub()'.
+ - POSIX compliance for `gsub()' and `sub()' with `--posix'.
- The `length()' function accepts an array argument and returns
the number of elements in the array (*note String
@@ -26098,24 +26371,24 @@ the current version of `gawk'.
* Additional functions only in `gawk':
- - The `and()', `compl()', `lshift()', `or()', `rshift()', and
- `xor()' functions for bit manipulation (*note Bitwise
- Functions::).
+ - The `gensub()', `patsplit()', and `strtonum()' functions for
+ more powerful text manipulation (*note String Functions::).
- The `asort()' and `asorti()' functions for sorting arrays
(*note Array Sorting::).
- - The `bindtextdomain()', `dcgettext()' and `dcngettext()'
- functions for internationalization (*note Programmer i18n::).
+ - The `mktime()', `systime()', and `strftime()' functions for
+ working with timestamps (*note Time Functions::).
- - The `fflush()' function from BWK `awk' (*note I/O
+ - The `and()', `compl()', `lshift()', `or()', `rshift()', and
+ `xor()' functions for bit manipulation (*note Bitwise
Functions::).
- - The `gensub()', `patsplit()', and `strtonum()' functions for
- more powerful text manipulation (*note String Functions::).
+ - The `isarray()' function to check if a variable is an array
+ or not (*note Type Functions::).
- - The `mktime()', `systime()', and `strftime()' functions for
- working with timestamps (*note Time Functions::).
+ - The `bindtextdomain()', `dcgettext()' and `dcngettext()'
+ functions for internationalization (*note Programmer i18n::).
* Changes and/or additions in the command-line options:
@@ -26167,10 +26440,12 @@ the current version of `gawk'.
* Support for the following obsolete systems was removed from the
- code and the documentation for `gawk' version 4.1:
+ code for `gawk' version 4.1:
- Ultrix
+ * Support for MirBSD was removed at `gawk' version 4.2.
+

File: gawk.info, Node: Feature History, Next: Common Extensions, Prev: POSIX/GNU, Up: Language History
@@ -26563,30 +26838,26 @@ File: gawk.info, Node: Common Extensions, Next: Ranges and Locales, Prev: Fea
A.7 Common Extensions Summary
=============================
-This minor node summarizes the common extensions supported by `gawk',
-Brian Kernighan's `awk', and `mawk', the three most widely-used freely
-available versions of `awk' (*note Other Versions::).
-
-Feature BWK Awk Mawk GNU Awk
---------------------------------------------------------
-`\x' Escape sequence X X X
-`FS' as null string X X X
-`/dev/stdin' special file X X X
-`/dev/stdout' special file X X X
-`/dev/stderr' special file X X X
-`delete' without subscript X X X
-`fflush()' function X X X
-`length()' of an array X X X
-`nextfile' statement X X X
-`**' and `**=' operators X X
-`func' keyword X X
-`BINMODE' variable X X
-`RS' as regexp X X
-Time related functions X X
-
- (Technically speaking, as of late 2012, `fflush()', `delete ARRAY',
-and `nextfile' are no longer extensions, since they have been added to
-POSIX.)
+The following table summarizes the common extensions supported by
+`gawk', Brian Kernighan's `awk', and `mawk', the three most widely-used
+freely available versions of `awk' (*note Other Versions::).
+
+Feature BWK Awk Mawk GNU Awk Now standard
+-----------------------------------------------------------------------
+`\x' Escape sequence X X X
+`FS' as null string X X X
+`/dev/stdin' special file X X X
+`/dev/stdout' special file X X X
+`/dev/stderr' special file X X X
+`delete' without subscript X X X X
+`fflush()' function X X X X
+`length()' of an array X X X
+`nextfile' statement X X X X
+`**' and `**=' operators X X
+`func' keyword X X
+`BINMODE' variable X X
+`RS' as regexp X X
+Time related functions X X

File: gawk.info, Node: Ranges and Locales, Next: Contributors, Prev: Common Extensions, Up: Language History
@@ -26627,14 +26898,14 @@ like `[a-dx-z]' is still equivalent to `[abcdxyz]', as in ASCII. But
outside those locales, the ordering was defined to be based on
"collation order".
- In many locales, `A' and `a' are both less than `B'. In other
-words, these locales sort characters in dictionary order, and
-`[a-dx-z]' is typically not equivalent to `[abcdxyz]'; instead it might
-be equivalent to `[ABCXYabcdxyz]', for example.
+ What does that mean? In many locales, `A' and `a' are both less
+than `B'. In other words, these locales sort characters in dictionary
+order, and `[a-dx-z]' is typically not equivalent to `[abcdxyz]';
+instead it might be equivalent to `[ABCXYabcdxyz]', for example.
This point needs to be emphasized: Much literature teaches that you
should use `[a-z]' to match a lowercase character. But on systems with
-non-ASCII locales, this also matched all of the uppercase characters
+non-ASCII locales, this also matches all of the uppercase characters
except `A' or `Z'! This was a continuous cause of confusion, even well
into the twenty-first century.
@@ -26761,7 +27032,7 @@ Info file, in approximate chronological order:
various PC platforms.
* Christos Zoulas provided the `extension()' built-in function for
- dynamically adding new modules. (This was obsoleted at `gawk'
+ dynamically adding new functions. (This was obsoleted at `gawk'
4.1.)
* Ju"rgen Kahrs contributed the initial version of the TCP/IP
@@ -26831,6 +27102,9 @@ Info file, in approximate chronological order:
4.1 was driven primarily by Arnold Robbins and Andrew Schorr, with
notable contributions from the rest of the development team.
+ * John Malmberg contributed significant improvements to the OpenVMS
+ port and the related documentation.
+
* Antonio Giovanni Colombo rewrote a number of examples in the early
chapters that were severely dated, for which I am incredibly
grateful.
@@ -26881,7 +27155,7 @@ This appendix provides instructions for installing `gawk' on the
various platforms that are supported by the developers. The primary
developer supports GNU/Linux (and Unix), whereas the other ports are
contributed. *Note Bugs::, for the electronic mail addresses of the
-people who did the respective ports.
+people who maintain the respective ports.
* Menu:
@@ -26924,7 +27198,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
@@ -26943,25 +27217,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
@@ -27172,12 +27446,12 @@ 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
-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
-*note (Autoconf)Top:: autoconf,Autoconf--Generating Automatic
-Configuration Scripts.)
+`gawk-4.1.2'. As with most GNU software, you configure `gawk' 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 *note
+(Autoconf)Top:: autoconf,Autoconf--Generating Automatic Configuration
+Scripts.)
To configure `gawk', simply run `configure':
@@ -27240,8 +27514,8 @@ command line when compiling `gawk' from scratch, including:
User-modified::) has no effect on the running `awk' program.
When used with GCC's automatic dead-code-elimination, this option
- cuts almost 200K bytes off the size of the `gawk' executable on
- GNU/Linux x86 systems. Results on other systems and with other
+ cuts almost 23K bytes off the size of the `gawk' executable on
+ GNU/Linux x86_64 systems. Results on other systems and with other
compilers are likely to vary. Using this option may bring you
some slight performance improvement.
@@ -27327,10 +27601,10 @@ File: gawk.info, Node: PC Installation, Next: VMS Installation, Up: Non-Unix
B.3.1 Installation on PC Operating Systems
------------------------------------------
-This minor node covers installation and usage of `gawk' on x86 machines
-running MS-DOS, any version of MS-Windows, or OS/2. In this minor
-node, the term "Windows32" refers to any of Microsoft
-Windows-95/98/ME/NT/2000/XP/Vista/7/8.
+This minor node covers installation and usage of `gawk' on Intel
+architecture machines running MS-DOS, any version of MS-Windows, or
+OS/2. In this minor node, the term "Windows32" refers to any of
+Microsoft Windows-95/98/ME/NT/2000/XP/Vista/7/8.
The limitations of MS-DOS (and MS-DOS shells under the other
operating systems) has meant that various "DOS extenders" are often
@@ -27415,7 +27689,7 @@ MS-DOS and Windows32 versions. A list of targets is printed if the
`gawk' using the DJGPP tools, enter `make djgpp'. (The DJGPP tools
needed for the build may be found at
`ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/'.) To build a native
-MS-Windows binary of `gawk', type `make mingw32'.
+MS-Windows binary of `gawk' using the MinGW tools, type `make mingw32'.
The 32 bit EMX version of `gawk' works "out of the box" under OS/2.
However, it is highly recommended to use GCC 2.95.3 for the compilation.
@@ -27507,8 +27781,8 @@ Networking::). EMX (OS/2 only) supports at least the `|&' operator.
The MS-DOS and MS-Windows versions of `gawk' search for program
files as described in *note AWKPATH Variable::. However, semicolons
(rather than colons) separate elements in the `AWKPATH' variable. If
-`AWKPATH' is not set or is empty, then the default search path for
-MS-Windows and MS-DOS versions is `.;c:/lib/awk;c:/gnu/lib/awk'.
+`AWKPATH' is not set or is empty, then the default search path is
+`.;c:/lib/awk;c:/gnu/lib/awk'.
The search path for OS/2 (32 bit, EMX) is determined by the prefix
directory (most likely `/usr' or `c:/usr') that has been specified as
@@ -27532,10 +27806,10 @@ programs) silently translate end-of-line `\r\n' to `\n' on input and
`\n' to `\r\n' on output. A special `BINMODE' variable (c.e.) allows
control over these translations and is interpreted as follows:
- * If `BINMODE' is `"r"', or one, then binary mode is set on read
+ * If `BINMODE' is `"r"' or one, then binary mode is set on read
(i.e., no translations on reads).
- * If `BINMODE' is `"w"', or two, then binary mode is set on write
+ * If `BINMODE' is `"w"' or two, then binary mode is set on write
(i.e., no translations on writes).
* If `BINMODE' is `"rw"' or `"wr"' or three, binary mode is set for
@@ -27599,10 +27873,10 @@ 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
+ make && make check
When compared to GNU/Linux on the same system, the `configure' step
on Cygwin takes considerably longer. However, it does finish, and then
@@ -27620,13 +27894,13 @@ 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
-B.3.2 How to Compile and Install `gawk' on Vax/VMS and OpenVMS
---------------------------------------------------------------
+B.3.2 Compiling and Installing `gawk' on Vax/VMS and OpenVMS
+------------------------------------------------------------
This node describes how to compile and install `gawk' under VMS. The
older designation "VMS" is used throughout to refer to OpenVMS.
@@ -27716,7 +27990,7 @@ than 32 bits.
/name=(as_is,short)
Compile time macros need to be defined before the first VMS-supplied
-header file is included.
+header file is included, as follows:
#if (__CRTL_VER >= 70200000) && !defined (__VAX)
#define _LARGEFILE 1
@@ -27730,6 +28004,12 @@ header file is included.
#endif
#endif
+ If you are writing your own extensions to run on VMS, you must
+supply these definitions yourself. The `config.h' file created when
+building `gawk' on VMS does this for you; if instead you use that file
+or a similar one, then you must remember to include it before any
+VMS-supplied header files.
+

File: gawk.info, Node: VMS Installation Details, Next: VMS Running, Prev: VMS Dynamic Extensions, Up: VMS Installation
@@ -27817,12 +28097,12 @@ If any other dash-type options (or multiple parameters such as data
files to process) are present, there is no ambiguity and `--' can be
omitted.
- The `exit' value is a Unix-style value and is encoded to a VMS exit
+ The `exit' value is a Unix-style value and is encoded into a VMS exit
status value when the program exits.
The VMS severity bits will be set based on the `exit' value. A
failure is indicated by 1 and VMS sets the `ERROR' status. A fatal
-error is indicated by 2 and VMS will set the `FATAL' status. All other
+error is indicated by 2 and VMS sets the `FATAL' status. All other
values will have the `SUCCESS' status. The exit value is encoded to
comply with VMS coding standards and will have the `C_FACILITY_NO' of
`0x350000' with the constant `0xA000' added to the number shifted over
@@ -27835,9 +28115,9 @@ by 3 bits to make room for the severity codes.
A C program that uses `exec()' to call `gawk' will get the original
Unix-style exit value.
- Older versions of `gawk' treated a Unix exit code 0 as 1, a failure
-as 2, a fatal error as 4, and passed all the other numbers through.
-This violated the VMS exit status coding requirements.
+ Older versions of `gawk' for VMS treated a Unix exit code 0 as 1, a
+failure as 2, a fatal error as 4, and passed all the other numbers
+through. This violated the VMS exit status coding requirements.
VAX/VMS floating point uses unbiased rounding. *Note Round
Function::.
@@ -27868,8 +28148,8 @@ reorganized to supply individual PCSI packages for each component. See
The normal build procedure for `gawk' produces a program that is
suitable for use with GNV.
- The `vms/gawk_build_steps.txt' in the source documents the procedure
-for building a VMS PCSI kit that is compatible with GNV.
+ The file `vms/gawk_build_steps.txt' in the distribution documents
+the procedure for building a VMS PCSI kit that is compatible with GNV.

File: gawk.info, Node: VMS Old Gawk, Prev: VMS GNV, Up: VMS Installation
@@ -27898,10 +28178,10 @@ B.4 Reporting Problems and Bugs
please report it to the developers; we cannot promise to do anything
but we might well want to fix it.
- Before reporting a bug, make sure you have actually found a real bug.
-Carefully reread the documentation and see if it really says you can do
-what you're trying to do. If it's not clear whether you should be able
-to do something or not, report that too; it's a bug in the
+ Before reporting a bug, please make sure you have really found a
+genuine bug. Carefully reread the documentation and see if it says you
+can do what you're trying to do. If it's not clear whether you should
+be able to do something or not, report that too; it's a bug in the
documentation!
Before reporting a bug or trying to fix it yourself, try to isolate
@@ -27915,20 +28195,21 @@ really in the documentation.
Please include the version number of `gawk' you are using. You can
get this information with the command `gawk --version'.
- Once you have a precise problem, send email to <bug-gawk@gnu.org>.
+ Once you have a precise problem description, send email to
+<bug-gawk@gnu.org>.
The `gawk' maintainers subscribe to this address and thus they will
-receive your bug report. If necessary, the primary maintainer can be
-reached directly at <arnold@skeeve.com>. The bug reporting address is
-preferred since the email list is archived at the GNU Project. _All
-email should be in English. This is the only language understood in
-common by all the maintainers._
+receive your bug report. Although you can send mail to the maintainers
+directly, the bug reporting address is preferred since the email list
+is archived at the GNU Project. _All email must be in English. This is
+the only language understood in common by all the maintainers._
CAUTION: Do _not_ try to report bugs in `gawk' by posting to the
Usenet/Internet newsgroup `comp.lang.awk'. While the `gawk'
developers do occasionally read this newsgroup, there is no
guarantee that we will see your posting. The steps described
- above are the official recognized ways for reporting bugs. Really.
+ above are the only official recognized way for reporting bugs.
+ Really.
NOTE: Many distributions of GNU/Linux and the various BSD-based
operating systems have their own bug reporting systems. If you
@@ -27937,30 +28218,30 @@ common by all the maintainers._
This is for two reasons. First, while some distributions forward
bug reports "upstream" to the GNU mailing list, many don't, so
- there is a good chance that the `gawk' maintainer won't even see
+ there is a good chance that the `gawk' maintainers won't even see
the bug report! Second, mail to the GNU list is archived, and
having everything at the GNU project keeps things self-contained
- and not dependant on other web sites.
+ and not dependant on other organizations.
Non-bug suggestions are always welcome as well. If you have
questions about things that are unclear in the documentation or are
-just obscure features, ask me; I will try to help you out, although I
-may not have the time to fix the problem. You can send me electronic
-mail at the Internet address noted previously.
+just obscure features, ask on the bug list; we will try to help you out
+if we can.
If you find bugs in one of the non-Unix ports of `gawk', please send
-an electronic mail message to the person who maintains that port. They
-are named in the following list, as well as in the `README' file in the
-`gawk' distribution. Information in the `README' file should be
-considered authoritative if it conflicts with this Info file.
+an electronic mail message to the bug list, with a copy to the person
+who maintains that port. They are named in the following list, as well
+as in the `README' file in the `gawk' distribution. Information in the
+`README' file should be considered authoritative if it conflicts with
+this Info file.
- The people maintaining the non-Unix ports of `gawk' are as follows:
+ The people maintaining the various `gawk' ports are:
+Unix and POSIX systems Arnold Robbins, <arnold@skeeve.com>.
MS-DOS with DJGPP Scott Deifik, <scottd.mail@sbcglobal.net>.
MS-Windows with MinGW Eli Zaretskii, <eliz@gnu.org>.
OS/2 Andreas Buening, <andreas.buening@nexgo.de>.
-VMS Pat Rankin, <r.pat.rankin@gmail.com>, and John
- Malmberg, <wb8tyw@qsl.net>.
+VMS John Malmberg, <wb8tyw@qsl.net>.
z/OS (OS/390) Dave Pitts, <dpitts@cozx.com>.
If your bug is also reproducible under Unix, please send a copy of
@@ -27976,7 +28257,7 @@ B.5 Other Freely Available `awk' Implementations
`// Do C++ comments work? answer: yes! of course' -- Michael
Brennan
- There are a number of other freely available `awk' implementations.
+There are a number of other freely available `awk' implementations.
This minor node briefly describes where to get them:
Unix `awk'
@@ -28047,9 +28328,9 @@ Unix `awk'
`pawk'
Nelson H.F. Beebe at the University of Utah has modified BWK `awk'
to provide timing and profiling information. It is different from
- `gawk' with the `--profile' option. (*note Profiling::), in that
- it uses CPU-based profiling, not line-count profiling. You may
- find it at either
+ `gawk' with the `--profile' option (*note Profiling::), in that it
+ uses CPU-based profiling, not line-count profiling. You may find
+ it at either
`ftp://ftp.math.utah.edu/pub/pawk/pawk-20030606.tar.gz' or
`http://www.math.utah.edu/pub/pawk/pawk-20030606.tar.gz'.
@@ -28065,11 +28346,11 @@ Busybox Awk
The OpenSolaris POSIX `awk'
The versions of `awk' in `/usr/xpg4/bin' and `/usr/xpg6/bin' on
Solaris are more-or-less POSIX-compliant. They are based on the
- `awk' from Mortice Kern Systems for PCs. This author was able to
- make this code compile and work under GNU/Linux with 1-2 hours of
- work. Making it more generally portable (using GNU Autoconf
- and/or Automake) would take more work, and this has not been done,
- at least to our knowledge.
+ `awk' from Mortice Kern Systems for PCs. We were able to make
+ this code compile and work under GNU/Linux with 1-2 hours of work.
+ Making it more generally portable (using GNU Autoconf and/or
+ Automake) would take more work, and this has not been done, at
+ least to our knowledge.
The source code used to be available from the OpenSolaris web site.
However, that project was ended and the web site shut down.
@@ -28125,9 +28406,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
@@ -28258,9 +28539,9 @@ there are several steps that you need to take in order to make it
possible to include them:
1. Before building the new feature into `gawk' itself, consider
- writing it as an extension module (*note Dynamic Extensions::).
- If that's not possible, continue with the rest of the steps in
- this list.
+ writing it as an extension (*note Dynamic Extensions::). If
+ that's not possible, continue with the rest of the steps in this
+ list.
2. Be prepared to sign the appropriate paperwork. In order for the
FSF to distribute your changes, you must either place those
@@ -28427,9 +28708,9 @@ steps:
6. Be willing to continue to maintain the port. Non-Unix operating
systems are supported by volunteers who maintain the code needed
- to compile and run `gawk' on their systems. If noone volunteers to
- maintain a port, it becomes unsupported and it may be necessary to
- remove it from the distribution.
+ to compile and run `gawk' on their systems. If no-one volunteers
+ to maintain a port, it becomes unsupported and it may be necessary
+ to remove it from the distribution.
7. Supply an appropriate `gawkmisc.???' file. Each port has its own
`gawkmisc.???' that implements certain operating system specific
@@ -28484,8 +28765,8 @@ the derived files, because that keeps the repository less cluttered,
and it is easier to see the substantive changes when comparing versions
and trying to understand what changed between commits.
- However, there are two reasons why the `gawk' maintainer likes to
-have everything in the repository.
+ However, there are several reasons why the `gawk' maintainer likes
+to have everything in the repository.
First, because it is then easy to reproduce any given version
completely, without relying upon the availability of (older, likely
@@ -28538,6 +28819,13 @@ maintainer is no different than Jane User who wants to try to build
Thus, the maintainer thinks that it's not just important, but
critical, that for any given branch, the above incantation _just works_.
+ A third reason to have all the files is that without them, using `git
+bisect' to try to find the commit that introduced a bug is exceedingly
+difficult. The maintainer tried to do that on another project that
+requires running bootstrapping scripts just to create `configure' and
+so on; it was really painful. When the repository is self-contained,
+using `git bisect' in it is very easy.
+
What are some of the consequences and/or actions to take?
1. We don't mind that there are differing files in the different
@@ -28809,7 +29097,7 @@ C.5.3 Other Design Decisions
----------------------------
As an arbitrary design decision, extensions can read the values of
-built-in variables and arrays (such as `ARGV' and `FS'), but cannot
+predefined variables and arrays (such as `ARGV' and `FS'), but cannot
change them, with the exception of `PROCINFO'.
The reason for this is to prevent an extension function from
@@ -29376,11 +29664,11 @@ FDL
Field
When `awk' reads an input record, it splits the record into pieces
separated by whitespace (or by a separator regexp that you can
- change by setting the built-in variable `FS'). Such pieces are
+ change by setting the predefined variable `FS'). Such pieces are
called fields. If the pieces are of fixed length, you can use the
built-in variable `FIELDWIDTHS' to describe their lengths. If you
wish to specify the contents of fields instead of the field
- separator, you can use the built-in variable `FPAT' to do so.
+ separator, you can use the predefined variable `FPAT' to do so.
(*Note Field Separators::, *note Constant Size::, and *note
Splitting By Content::.)
@@ -29397,7 +29685,7 @@ Format
Format strings control the appearance of output in the
`strftime()' and `sprintf()' functions, and in the `printf'
statement as well. Also, data conversions from numbers to strings
- are controlled by the format strings contained in the built-in
+ are controlled by the format strings contained in the predefined
variables `CONVFMT' and `OFMT'. (*Note Control Letters::.)
Free Documentation License
@@ -30964,7 +31252,7 @@ Index
* Menu:
-* ! (exclamation point), ! operator: Boolean Ops. (line 67)
+* ! (exclamation point), ! operator: Boolean Ops. (line 69)
* ! (exclamation point), ! operator <1>: Egrep Program. (line 175)
* ! (exclamation point), ! operator <2>: Ranges. (line 48)
* ! (exclamation point), ! operator: Precedence. (line 52)
@@ -30977,10 +31265,9 @@ Index
* ! (exclamation point), !~ operator <3>: Comparison Operators.
(line 11)
* ! (exclamation point), !~ operator <4>: Regexp Constants. (line 6)
-* ! (exclamation point), !~ operator <5>: Computed Regexps. (line 6)
-* ! (exclamation point), !~ operator <6>: Case-sensitivity. (line 26)
+* ! (exclamation point), !~ operator <5>: Case-sensitivity. (line 26)
+* ! (exclamation point), !~ operator <6>: Computed Regexps. (line 6)
* ! (exclamation point), !~ operator: Regexp Usage. (line 19)
-* " (double quote) in shell commands: Read Terminal. (line 25)
* " (double quote), in regexp constants: Computed Regexps. (line 29)
* " (double quote), in shell commands: Quoting. (line 54)
* # (number sign), #! (executable scripts): Executable Scripts.
@@ -30995,22 +31282,22 @@ Index
* % (percent sign), %= operator <1>: Precedence. (line 95)
* % (percent sign), %= operator: Assignment Ops. (line 130)
* & (ampersand), && operator <1>: Precedence. (line 86)
-* & (ampersand), && operator: Boolean Ops. (line 57)
+* & (ampersand), && operator: Boolean Ops. (line 59)
* & (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 80)
+* () (parentheses), regexp operator: Regexp Operators. (line 81)
* * (asterisk), * operator, as multiplication operator: Precedence.
(line 55)
* * (asterisk), * operator, as regexp operator: Regexp Operators.
- (line 88)
-* * (asterisk), * operator, null strings, matching: Gory Details.
- (line 143)
+ (line 89)
+* * (asterisk), * operator, null strings, matching: String Functions.
+ (line 535)
* * (asterisk), ** operator <1>: Precedence. (line 49)
* * (asterisk), ** operator: Arithmetic Ops. (line 81)
* * (asterisk), **= operator <1>: Precedence. (line 95)
@@ -31022,7 +31309,7 @@ Index
* + (plus sign), ++ operator: Increment Ops. (line 11)
* + (plus sign), += operator <1>: Precedence. (line 95)
* + (plus sign), += operator: Assignment Ops. (line 82)
-* + (plus sign), regexp operator: Regexp Operators. (line 103)
+* + (plus sign), regexp operator: Regexp Operators. (line 105)
* , (comma), in range patterns: Ranges. (line 6)
* - (hyphen), - operator: Precedence. (line 52)
* - (hyphen), -- operator <1>: Precedence. (line 46)
@@ -31054,30 +31341,30 @@ Index
* --include option: Options. (line 159)
* --lint option <1>: Options. (line 185)
* --lint option: Command Line. (line 20)
-* --lint-old option: Options. (line 293)
+* --lint-old option: Options. (line 295)
* --load option: Options. (line 173)
* --non-decimal-data option <1>: Nondecimal Data. (line 6)
* --non-decimal-data option: Options. (line 211)
* --non-decimal-data option, strtonum() function and: Nondecimal Data.
- (line 36)
-* --optimize option: Options. (line 235)
-* --posix option: Options. (line 252)
-* --posix option, --traditional option and: Options. (line 271)
-* --pretty-print option: Options. (line 224)
+ (line 35)
+* --optimize option: Options. (line 237)
+* --posix option: Options. (line 254)
+* --posix option, --traditional option and: Options. (line 273)
+* --pretty-print option: Options. (line 226)
* --profile option <1>: Profiling. (line 12)
-* --profile option: Options. (line 240)
-* --re-interval option: Options. (line 277)
-* --sandbox option: Options. (line 284)
+* --profile option: Options. (line 242)
+* --re-interval option: Options. (line 279)
+* --sandbox option: Options. (line 286)
* --sandbox option, disabling system() function: I/O Functions.
- (line 97)
+ (line 96)
* --sandbox option, input redirection with getline: Getline. (line 19)
* --sandbox option, output redirection with print, printf: Redirection.
(line 6)
* --source option: Options. (line 117)
* --traditional option: Options. (line 81)
-* --traditional option, --posix option and: Options. (line 271)
-* --use-lc-numeric option: Options. (line 219)
-* --version option: Options. (line 298)
+* --traditional option, --posix option and: Options. (line 273)
+* --use-lc-numeric option: Options. (line 221)
+* --version option: Options. (line 300)
* --with-whiny-user-strftime configuration option: Additional Configuration Options.
(line 35)
* -b option: Options. (line 68)
@@ -31085,42 +31372,42 @@ Index
* -c option: Options. (line 81)
* -D option: Options. (line 108)
* -d option: Options. (line 93)
-* -e option: Options. (line 333)
+* -e option: Options. (line 336)
* -E option: Options. (line 125)
* -e option: Options. (line 117)
* -f option: Options. (line 25)
* -F option: Options. (line 21)
* -f option: Long. (line 12)
-* -F option, -Ft sets FS to TAB: Options. (line 306)
+* -F option, -Ft sets FS to TAB: Options. (line 308)
* -F option, command-line: Command Line Field Separator.
(line 6)
-* -f option, multiple uses: Options. (line 311)
+* -f option, multiple uses: Options. (line 313)
* -g option: Options. (line 147)
* -h option: Options. (line 154)
* -i option: Options. (line 159)
-* -L option: Options. (line 293)
+* -L option: Options. (line 295)
* -l option: Options. (line 173)
* -M option: Options. (line 205)
-* -N option: Options. (line 219)
+* -N option: Options. (line 221)
* -n option: Options. (line 211)
-* -O option: Options. (line 235)
-* -o option: Options. (line 224)
-* -P option: Options. (line 252)
-* -p option: Options. (line 240)
-* -r option: Options. (line 277)
-* -S option: Options. (line 284)
+* -O option: Options. (line 237)
+* -o option: Options. (line 226)
+* -P option: Options. (line 254)
+* -p option: Options. (line 242)
+* -r option: Options. (line 279)
+* -S option: Options. (line 286)
* -v option: Assignment Options. (line 12)
-* -V option: Options. (line 298)
+* -V option: Options. (line 300)
* -v option: Options. (line 32)
* -W option: Options. (line 46)
* . (period), regexp operator: Regexp Operators. (line 44)
* .gmo files: Explaining gettext. (line 42)
* .gmo files, specifying directory of <1>: Programmer i18n. (line 47)
* .gmo files, specifying directory of: Explaining gettext. (line 54)
-* .mo files, converting from .po: I18N Example. (line 63)
+* .mo files, converting from .po: I18N Example. (line 64)
* .po files <1>: Translator i18n. (line 6)
* .po files: Explaining gettext. (line 37)
-* .po files, converting to .mo: I18N Example. (line 63)
+* .po files, converting to .mo: I18N Example. (line 64)
* .pot files: Explaining gettext. (line 31)
* / (forward slash) to enclose regular expressions: Regexp. (line 10)
* / (forward slash), / operator: Precedence. (line 55)
@@ -31130,8 +31417,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 48)
+* /dev/fd/N special files (gawk): Special FD. (line 48)
* /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)
@@ -31165,11 +31452,14 @@ Index
* ? (question mark), ?: operator: Precedence. (line 92)
* ? (question mark), regexp operator <1>: GNU Regexp Operators.
(line 59)
-* ? (question mark), regexp operator: Regexp Operators. (line 112)
+* ? (question mark), regexp operator: Regexp Operators. (line 111)
+* @-notation for indirect function calls: Indirect Calls. (line 47)
+* @include directive: Include Files. (line 8)
+* @load directive: Loading Shared Libraries.
+ (line 8)
* [] (square brackets), regexp operator: Regexp Operators. (line 56)
* \ (backslash): Comments. (line 50)
-* \ (backslash) in shell commands: Read Terminal. (line 25)
-* \ (backslash), \" escape sequence: Escape Sequences. (line 82)
+* \ (backslash), \" escape sequence: Escape Sequences. (line 84)
* \ (backslash), \' operator (gawk): GNU Regexp Operators.
(line 56)
* \ (backslash), \/ escape sequence: Escape Sequences. (line 75)
@@ -31201,8 +31491,7 @@ Index
* \ (backslash), \y operator (gawk): GNU Regexp Operators.
(line 38)
* \ (backslash), as field separator: Command Line Field Separator.
- (line 27)
-* \ (backslash), continuing lines and <1>: Egrep Program. (line 223)
+ (line 24)
* \ (backslash), continuing lines and: Statements/Lines. (line 19)
* \ (backslash), continuing lines and, comments and: Statements/Lines.
(line 76)
@@ -31213,7 +31502,7 @@ Index
* \ (backslash), in bracket expressions: Bracket Expressions. (line 17)
* \ (backslash), in escape sequences: Escape Sequences. (line 6)
* \ (backslash), in escape sequences, POSIX and: Escape Sequences.
- (line 118)
+ (line 120)
* \ (backslash), in regexp constants: Computed Regexps. (line 29)
* \ (backslash), in shell commands: Quoting. (line 48)
* \ (backslash), regexp operator: Regexp Operators. (line 18)
@@ -31265,12 +31554,12 @@ Index
* ambiguity, syntactic: /= operator vs. /=.../ regexp constant: Assignment Ops.
(line 148)
* ampersand (&), && operator <1>: Precedence. (line 86)
-* ampersand (&), && operator: Boolean Ops. (line 57)
+* ampersand (&), && operator: Boolean Ops. (line 59)
* ampersand (&), gsub()/gensub()/sub() functions and: Gory Details.
(line 6)
-* anagram.awk program: Anagram Program. (line 22)
+* anagram.awk program: Anagram Program. (line 21)
* anagrams, finding: Anagram Program. (line 6)
-* and: Bitwise Functions. (line 39)
+* and: Bitwise Functions. (line 40)
* AND bitwise operation: Bitwise Functions. (line 6)
* and Boolean-logic operator: Boolean Ops. (line 6)
* ANSI: Glossary. (line 34)
@@ -31286,33 +31575,33 @@ 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 42)
+* 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.
(line 6)
* array scanning order, controlling: Controlling Scanning.
(line 14)
-* array, number of elements: String Functions. (line 197)
+* array, number of elements: String Functions. (line 200)
* arrays: Arrays. (line 6)
* arrays of arrays: Arrays of Arrays. (line 6)
* arrays, an example of using: Array Example. (line 6)
-* arrays, and IGNORECASE variable: Array Intro. (line 92)
+* arrays, and IGNORECASE variable: Array Intro. (line 94)
* arrays, as parameters to functions: Pass By Value/Reference.
(line 47)
* arrays, associative: Array Intro. (line 50)
-* arrays, associative, library functions and: Library Names. (line 57)
+* arrays, associative, library functions and: Library Names. (line 58)
* arrays, deleting entire contents: Delete. (line 39)
* arrays, elements that don't exist: Reference to Elements.
(line 23)
@@ -31320,13 +31609,12 @@ Index
* arrays, elements, deleting: Delete. (line 6)
* arrays, elements, order of access by in operator: Scanning an Array.
(line 48)
-* arrays, elements, retrieving number of: String Functions. (line 42)
+* arrays, elements, retrieving number of: String Functions. (line 41)
* arrays, for statement and: Scanning an Array. (line 20)
* arrays, indexing: Array Intro. (line 50)
* arrays, merging into strings: Join Function. (line 6)
* arrays, multidimensional: Multidimensional. (line 10)
* arrays, multidimensional, scanning: Multiscanning. (line 11)
-* arrays, names of, and names of functions/variables: Arrays. (line 18)
* arrays, numeric subscripts: Numeric Array Subscripts.
(line 6)
* arrays, referencing elements: Reference to Elements.
@@ -31336,7 +31624,7 @@ Index
(line 6)
* arrays, sorting, and IGNORECASE variable: Array Sorting Functions.
(line 83)
-* arrays, sparse: Array Intro. (line 71)
+* arrays, sparse: Array Intro. (line 72)
* arrays, subscripts, uninitialized variables as: Uninitialized Subscripts.
(line 6)
* arrays, unassigned elements: Reference to Elements.
@@ -31347,12 +31635,12 @@ Index
* ASCII: Ordinal Functions. (line 45)
* asort <1>: Array Sorting Functions.
(line 6)
-* asort: String Functions. (line 42)
+* asort: String Functions. (line 41)
* asort() function (gawk), arrays, sorting: Array Sorting Functions.
(line 6)
* asorti <1>: Array Sorting Functions.
(line 6)
-* asorti: String Functions. (line 42)
+* asorti: String Functions. (line 41)
* asorti() function (gawk), arrays, sorting: Array Sorting Functions.
(line 6)
* assert() function (C library): Assert Function. (line 6)
@@ -31368,9 +31656,9 @@ Index
* asterisk (*), * operator, as multiplication operator: Precedence.
(line 55)
* asterisk (*), * operator, as regexp operator: Regexp Operators.
- (line 88)
-* asterisk (*), * operator, null strings, matching: Gory Details.
- (line 143)
+ (line 89)
+* asterisk (*), * operator, null strings, matching: String Functions.
+ (line 535)
* asterisk (*), ** operator <1>: Precedence. (line 49)
* asterisk (*), ** operator: Arithmetic Ops. (line 81)
* asterisk (*), **= operator <1>: Precedence. (line 95)
@@ -31382,11 +31670,11 @@ Index
* awf (amazingly workable formatter) program: Glossary. (line 24)
* awk debugging, enabling: Options. (line 108)
* awk language, POSIX version: Assignment Ops. (line 137)
-* awk profiling, enabling: Options. (line 240)
+* awk profiling, enabling: Options. (line 242)
* awk programs <1>: Two Rules. (line 6)
* awk programs <2>: Executable Scripts. (line 6)
* awk programs: Getting Started. (line 12)
-* awk programs, complex: When. (line 29)
+* awk programs, complex: When. (line 27)
* awk programs, documenting <1>: Library Names. (line 6)
* awk programs, documenting: Comments. (line 6)
* awk programs, examples of: Sample Programs. (line 6)
@@ -31408,7 +31696,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)
@@ -31417,14 +31705,13 @@ Index
* awk, POSIX and: Preface. (line 21)
* awk, POSIX and, See Also POSIX awk: Preface. (line 21)
* awk, regexp constants and: Comparison Operators.
- (line 102)
+ (line 103)
* awk, See Also gawk: Preface. (line 34)
* awk, terms describing: This Manual. (line 6)
* awk, uses for <1>: When. (line 6)
* awk, uses for <2>: Getting Started. (line 12)
* awk, uses for: Preface. (line 21)
-* awk, versions of <1>: V7/SVR3.1. (line 6)
-* awk, versions of: Names. (line 10)
+* awk, versions of: V7/SVR3.1. (line 6)
* awk, versions of, changes between SVR3.1 and SVR4: SVR4. (line 6)
* awk, versions of, changes between SVR4 and POSIX awk: POSIX.
(line 6)
@@ -31441,8 +31728,7 @@ Index
* awkvars.out file: Options. (line 93)
* b debugger command (alias for break): Breakpoint Control. (line 11)
* backslash (\): Comments. (line 50)
-* backslash (\) in shell commands: Read Terminal. (line 25)
-* backslash (\), \" escape sequence: Escape Sequences. (line 82)
+* backslash (\), \" escape sequence: Escape Sequences. (line 84)
* backslash (\), \' operator (gawk): GNU Regexp Operators.
(line 56)
* backslash (\), \/ escape sequence: Escape Sequences. (line 75)
@@ -31474,8 +31760,7 @@ Index
* backslash (\), \y operator (gawk): GNU Regexp Operators.
(line 38)
* backslash (\), as field separator: Command Line Field Separator.
- (line 27)
-* backslash (\), continuing lines and <1>: Egrep Program. (line 223)
+ (line 24)
* backslash (\), continuing lines and: Statements/Lines. (line 19)
* backslash (\), continuing lines and, comments and: Statements/Lines.
(line 76)
@@ -31486,7 +31771,7 @@ Index
* backslash (\), in bracket expressions: Bracket Expressions. (line 17)
* backslash (\), in escape sequences: Escape Sequences. (line 6)
* backslash (\), in escape sequences, POSIX and: Escape Sequences.
- (line 118)
+ (line 120)
* backslash (\), in regexp constants: Computed Regexps. (line 29)
* backslash (\), in shell commands: Quoting. (line 48)
* backslash (\), regexp operator: Regexp Operators. (line 18)
@@ -31504,20 +31789,20 @@ Index
* BEGIN pattern, getline and: Getline Notes. (line 19)
* BEGIN pattern, headings, adding: Print Examples. (line 43)
* BEGIN pattern, next/nextfile statements and <1>: Next Statement.
- (line 45)
+ (line 44)
* BEGIN pattern, next/nextfile statements and: I/O And BEGIN/END.
- (line 36)
+ (line 37)
* BEGIN pattern, OFS/ORS variables, assigning values to: Output Separators.
(line 20)
* BEGIN pattern, operators and: Using BEGIN/END. (line 17)
* BEGIN pattern, print statement and: I/O And BEGIN/END. (line 16)
* BEGIN pattern, pwcat program: Passwd Functions. (line 143)
-* BEGIN pattern, running awk programs and: Cut Program. (line 68)
+* BEGIN pattern, running awk programs and: Cut Program. (line 63)
* BEGIN pattern, TEXTDOMAIN variable and: Programmer i18n. (line 60)
* BEGINFILE pattern: BEGINFILE/ENDFILE. (line 6)
* BEGINFILE pattern, Boolean patterns and: Expression Patterns.
(line 70)
-* beginfile() user-defined function: Filetrans Function. (line 62)
+* beginfile() user-defined function: Filetrans Function. (line 61)
* Bentley, Jon: Glossary. (line 143)
* Benzinger, Michael: Contributors. (line 97)
* Berry, Karl <1>: Ranges and Locales. (line 74)
@@ -31531,11 +31816,11 @@ Index
* BINMODE variable <1>: PC Using. (line 33)
* BINMODE variable: User-modified. (line 15)
* bit-manipulation functions: Bitwise Functions. (line 6)
-* bits2str() user-defined function: Bitwise Functions. (line 70)
-* bitwise AND: Bitwise Functions. (line 39)
-* bitwise complement: Bitwise Functions. (line 43)
-* bitwise OR: Bitwise Functions. (line 49)
-* bitwise XOR: Bitwise Functions. (line 55)
+* bits2str() user-defined function: Bitwise Functions. (line 71)
+* bitwise AND: Bitwise Functions. (line 40)
+* bitwise complement: Bitwise Functions. (line 44)
+* bitwise OR: Bitwise Functions. (line 50)
+* bitwise XOR: Bitwise Functions. (line 56)
* bitwise, complement: Bitwise Functions. (line 25)
* bitwise, operations: Bitwise Functions. (line 6)
* bitwise, shift: Bitwise Functions. (line 32)
@@ -31551,15 +31836,15 @@ Index
* bracket expressions <1>: Bracket Expressions. (line 6)
* bracket expressions: Regexp Operators. (line 56)
* bracket expressions, character classes: Bracket Expressions.
- (line 30)
+ (line 32)
* bracket expressions, collating elements: Bracket Expressions.
- (line 77)
+ (line 79)
* bracket expressions, collating symbols: Bracket Expressions.
- (line 84)
+ (line 86)
* bracket expressions, complemented: Regexp Operators. (line 64)
* bracket expressions, equivalence classes: Bracket Expressions.
- (line 90)
-* bracket expressions, non-ASCII: Bracket Expressions. (line 77)
+ (line 92)
+* bracket expressions, non-ASCII: Bracket Expressions. (line 79)
* bracket expressions, range expressions: Bracket Expressions.
(line 6)
* break debugger command: Breakpoint Control. (line 11)
@@ -31575,12 +31860,12 @@ Index
* Brennan, Michael <1>: Other Versions. (line 6)
* Brennan, Michael <2>: Simple Sed. (line 25)
* Brennan, Michael <3>: Delete. (line 56)
-* Brennan, Michael <4>: Acknowledgments. (line 76)
+* Brennan, Michael <4>: Acknowledgments. (line 78)
* Brennan, Michael: Foreword. (line 83)
* Brian Kernighan's awk <1>: I/O Functions. (line 43)
* Brian Kernighan's awk <2>: Gory Details. (line 19)
-* Brian Kernighan's awk <3>: String Functions. (line 490)
-* Brian Kernighan's awk <4>: Delete. (line 48)
+* Brian Kernighan's awk <3>: String Functions. (line 491)
+* Brian Kernighan's awk <4>: Delete. (line 51)
* Brian Kernighan's awk <5>: Nextfile Statement. (line 47)
* Brian Kernighan's awk <6>: Continue Statement. (line 44)
* Brian Kernighan's awk <7>: Break Statement. (line 51)
@@ -31591,7 +31876,7 @@ Index
(line 67)
* Brian Kernighan's awk <12>: GNU Regexp Operators.
(line 83)
-* Brian Kernighan's awk <13>: Escape Sequences. (line 122)
+* Brian Kernighan's awk <13>: Escape Sequences. (line 124)
* Brian Kernighan's awk: When. (line 21)
* Brian Kernighan's awk, extensions: BTL. (line 6)
* Brian Kernighan's awk, source code: Other Versions. (line 13)
@@ -31601,12 +31886,12 @@ Index
* Brown, Martin: Contributors. (line 82)
* BSD-based operating systems: Glossary. (line 611)
* bt debugger command (alias for backtrace): Execution Stack. (line 13)
-* Buening, Andreas <1>: Bugs. (line 71)
+* Buening, Andreas <1>: Bugs. (line 72)
* Buening, Andreas <2>: Contributors. (line 92)
* Buening, Andreas: Acknowledgments. (line 60)
* buffering, input/output <1>: Two-way I/O. (line 52)
-* buffering, input/output: I/O Functions. (line 140)
-* buffering, interactive vs. noninteractive: I/O Functions. (line 109)
+* buffering, input/output: I/O Functions. (line 139)
+* buffering, interactive vs. noninteractive: I/O Functions. (line 108)
* buffers, flushing: I/O Functions. (line 32)
* buffers, operators for: GNU Regexp Operators.
(line 48)
@@ -31614,11 +31899,8 @@ Index
* bug-gawk@gnu.org bug reporting address: Bugs. (line 30)
* built-in functions: Functions. (line 6)
* built-in functions, evaluation order: Calling Built-in. (line 30)
-* built-in variables: Built-in Variables. (line 6)
-* built-in variables, -v option, setting with: Options. (line 40)
-* built-in variables, conveying information: Auto-set. (line 6)
-* built-in variables, user-modifiable: User-modified. (line 6)
* Busybox Awk: Other Versions. (line 88)
+* c.e., See common extensions: Conventions. (line 51)
* call by reference: Pass By Value/Reference.
(line 47)
* call by value: Pass By Value/Reference.
@@ -31634,8 +31916,8 @@ Index
* case keyword: Switch Statement. (line 6)
* case sensitivity, and regexps: User-modified. (line 76)
* case sensitivity, and string comparisons: User-modified. (line 76)
-* case sensitivity, array indices and: Array Intro. (line 92)
-* case sensitivity, converting case: String Functions. (line 520)
+* case sensitivity, array indices and: Array Intro. (line 94)
+* case sensitivity, converting case: String Functions. (line 521)
* case sensitivity, example programs: Library Functions. (line 53)
* case sensitivity, gawk: Case-sensitivity. (line 26)
* case sensitivity, regexps and: Case-sensitivity. (line 6)
@@ -31671,14 +31953,14 @@ 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)
* Collado, Manuel: Acknowledgments. (line 60)
-* collating elements: Bracket Expressions. (line 77)
-* collating symbols: Bracket Expressions. (line 84)
-* Colombo, Antonio <1>: Contributors. (line 137)
+* collating elements: Bracket Expressions. (line 79)
+* collating symbols: Bracket Expressions. (line 86)
+* Colombo, Antonio <1>: Contributors. (line 140)
* Colombo, Antonio: Acknowledgments. (line 60)
* columns, aligning: Print Examples. (line 70)
* columns, cutting: Cut Program. (line 6)
@@ -31707,15 +31989,15 @@ 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 48)
+* common extensions, /dev/stdin special file: Special FD. (line 48)
+* common extensions, /dev/stdout special file: Special FD. (line 48)
* 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)
-* common extensions, func keyword: Definition Syntax. (line 89)
+* common extensions, func keyword: Definition Syntax. (line 93)
* common extensions, length() applied to an array: String Functions.
- (line 197)
+ (line 200)
* common extensions, RS as a regexp: gawk split records. (line 6)
* common extensions, single character fields: Single Character Fields.
(line 6)
@@ -31724,7 +32006,7 @@ Index
(line 9)
* comparison expressions, as patterns: Expression Patterns. (line 14)
* comparison expressions, string vs. regexp: Comparison Operators.
- (line 78)
+ (line 79)
* compatibility mode (gawk), extensions: POSIX/GNU. (line 6)
* compatibility mode (gawk), file names: Special Caveats. (line 9)
* compatibility mode (gawk), hexadecimal numbers: Nondecimal-numbers.
@@ -31738,7 +32020,7 @@ Index
* compiling gawk for MS-DOS and MS-Windows: PC Compiling. (line 13)
* compiling gawk for VMS: VMS Compilation. (line 6)
* compiling gawk with EMX for OS/2: PC Compiling. (line 28)
-* compl: Bitwise Functions. (line 43)
+* compl: Bitwise Functions. (line 44)
* complement, bitwise: Bitwise Functions. (line 25)
* compound statements, control statements and: Statements. (line 10)
* concatenating: Concatenation. (line 8)
@@ -31764,15 +32046,15 @@ Index
* control statements: Statements. (line 6)
* controlling array scanning order: Controlling Scanning.
(line 14)
-* convert string to lower case: String Functions. (line 521)
-* convert string to number: String Functions. (line 388)
-* convert string to upper case: String Functions. (line 527)
+* convert string to lower case: String Functions. (line 522)
+* convert string to number: String Functions. (line 389)
+* convert string to upper case: String Functions. (line 528)
* converting integer array subscripts: Numeric Array Subscripts.
(line 31)
* converting, dates to timestamps: Time Functions. (line 76)
-* converting, numbers to strings <1>: Bitwise Functions. (line 109)
+* converting, numbers to strings <1>: Bitwise Functions. (line 110)
* converting, numbers to strings: Strings And Numbers. (line 6)
-* converting, strings to numbers <1>: Bitwise Functions. (line 109)
+* converting, strings to numbers <1>: Bitwise Functions. (line 110)
* converting, strings to numbers: Strings And Numbers. (line 6)
* CONVFMT variable <1>: User-modified. (line 30)
* CONVFMT variable: Strings And Numbers. (line 29)
@@ -31780,7 +32062,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)
@@ -31788,7 +32070,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 351)
+* 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)
@@ -31813,25 +32095,25 @@ 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 31)
+* dark corner, escape sequences: Other Arguments. (line 38)
* dark corner, escape sequences, for metacharacters: Escape Sequences.
- (line 140)
+ (line 142)
* dark corner, exit statement: Exit Statement. (line 30)
* dark corner, field separators: Field Splitting Summary.
(line 46)
* dark corner, FILENAME variable <1>: Auto-set. (line 98)
* dark corner, FILENAME variable: Getline Notes. (line 19)
-* dark corner, FNR/NR variables: Auto-set. (line 309)
+* dark corner, FNR/NR variables: Auto-set. (line 321)
* 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, length() function: String Functions. (line 186)
* dark corner, locale's decimal point character: Locale influences conversions.
(line 17)
* dark corner, multiline records: Multiple Line. (line 35)
@@ -31843,7 +32125,7 @@ Index
(line 148)
* dark corner, regexp constants, as arguments to user-defined functions: Using Constant Regexps.
(line 43)
-* dark corner, split() function: String Functions. (line 359)
+* dark corner, split() function: String Functions. (line 360)
* dark corner, strings, storing: gawk split records. (line 83)
* dark corner, value of ARGV[0]: Auto-set. (line 39)
* data, fixed-width: Constant Size. (line 10)
@@ -31857,7 +32139,7 @@ Index
(line 112)
* Davies, Stephen <1>: Contributors. (line 74)
* Davies, Stephen: Acknowledgments. (line 60)
-* Day, Robert P.J.: Acknowledgments. (line 76)
+* Day, Robert P.J.: Acknowledgments. (line 78)
* dcgettext <1>: Programmer i18n. (line 19)
* dcgettext: I18N Functions. (line 22)
* dcgettext() function (gawk), portability and: I18N Portability.
@@ -31884,7 +32166,7 @@ Index
* debugger commands, disable: Breakpoint Control. (line 69)
* debugger commands, display: Viewing And Changing Data.
(line 8)
-* debugger commands, down: Execution Stack. (line 21)
+* debugger commands, down: Execution Stack. (line 23)
* debugger commands, dump: Miscellaneous Debugger Commands.
(line 9)
* debugger commands, e (enable): Breakpoint Control. (line 73)
@@ -31893,10 +32175,10 @@ Index
(line 10)
* debugger commands, eval: Viewing And Changing Data.
(line 23)
-* debugger commands, f (frame): Execution Stack. (line 25)
+* debugger commands, f (frame): Execution Stack. (line 27)
* debugger commands, finish: Debugger Execution Control.
(line 39)
-* debugger commands, frame: Execution Stack. (line 25)
+* debugger commands, frame: Execution Stack. (line 27)
* debugger commands, h (help): Miscellaneous Debugger Commands.
(line 66)
* debugger commands, help: Miscellaneous Debugger Commands.
@@ -31958,11 +32240,12 @@ Index
(line 83)
* debugger commands, unwatch: Viewing And Changing Data.
(line 84)
-* debugger commands, up: Execution Stack. (line 34)
+* debugger commands, up: Execution Stack. (line 36)
* debugger commands, w (watch): Viewing And Changing Data.
(line 67)
* debugger commands, watch: Viewing And Changing Data.
(line 67)
+* debugger commands, where (backtrace): Execution Stack. (line 13)
* debugger default list amount: Debugger Info. (line 69)
* debugger history file: Debugger Info. (line 80)
* debugger history size: Debugger Info. (line 65)
@@ -31972,10 +32255,10 @@ Index
* debugger, read commands from a file: Debugger Info. (line 96)
* debugging awk programs: Debugger. (line 6)
* debugging gawk, bug reports: Bugs. (line 9)
-* decimal point character, locale specific: Options. (line 268)
+* decimal point character, locale specific: Options. (line 270)
* decrement operators: Increment Ops. (line 35)
* default keyword: Switch Statement. (line 6)
-* Deifik, Scott <1>: Bugs. (line 71)
+* Deifik, Scott <1>: Bugs. (line 72)
* Deifik, Scott <2>: Contributors. (line 53)
* Deifik, Scott: Acknowledgments. (line 60)
* delete ARRAY: Delete. (line 39)
@@ -31989,7 +32272,7 @@ Index
* deleting entire arrays: Delete. (line 39)
* Demaille, Akim: Acknowledgments. (line 60)
* describe call stack frame, in debugger: Debugger Info. (line 27)
-* differences between gawk and awk: String Functions. (line 197)
+* differences between gawk and awk: String Functions. (line 200)
* differences in awk and gawk, ARGC/ARGV variables: ARGC and ARGV.
(line 90)
* differences in awk and gawk, ARGIND variable: Auto-set. (line 44)
@@ -32012,7 +32295,7 @@ Index
* differences in awk and gawk, command-line directories: Command-line directories.
(line 6)
* differences in awk and gawk, ERRNO variable: Auto-set. (line 82)
-* differences in awk and gawk, error messages: Special FD. (line 16)
+* differences in awk and gawk, error messages: Special FD. (line 19)
* differences in awk and gawk, FIELDWIDTHS variable: User-modified.
(line 37)
* differences in awk and gawk, FPAT variable: User-modified. (line 43)
@@ -32023,48 +32306,48 @@ 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.
(line 34)
* differences in awk and gawk, LINT variable: User-modified. (line 88)
* differences in awk and gawk, match() function: String Functions.
- (line 260)
+ (line 262)
* differences in awk and gawk, print/printf statements: Format Modifiers.
(line 13)
-* differences in awk and gawk, PROCINFO array: Auto-set. (line 136)
+* differences in awk and gawk, PROCINFO array: Auto-set. (line 137)
* 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.
(line 26)
* differences in awk and gawk, RS/RT variables: gawk split records.
(line 58)
-* differences in awk and gawk, RT variable: Auto-set. (line 265)
+* differences in awk and gawk, RT variable: Auto-set. (line 272)
* differences in awk and gawk, single-character fields: Single Character Fields.
(line 6)
* differences in awk and gawk, split() function: String Functions.
- (line 347)
+ (line 348)
* differences in awk and gawk, strings: Scalar Constants. (line 20)
* differences in awk and gawk, strings, storing: gawk split records.
(line 77)
-* differences in awk and gawk, SYMTAB variable: Auto-set. (line 269)
+* differences in awk and gawk, SYMTAB variable: Auto-set. (line 276)
* differences in awk and gawk, TEXTDOMAIN variable: User-modified.
- (line 152)
+ (line 151)
* differences in awk and gawk, trunc-mod operation: Arithmetic Ops.
(line 66)
* directories, command-line: Command-line directories.
(line 6)
-* directories, searching: Programs Exercises. (line 63)
+* directories, searching: Programs Exercises. (line 70)
* directories, searching for loadable extensions: AWKLIBPATH Variable.
(line 6)
* directories, searching for source files: AWKPATH Variable. (line 6)
@@ -32085,11 +32368,11 @@ Index
* dollar sign ($), incrementing fields and arrays: Increment Ops.
(line 30)
* dollar sign ($), regexp operator: Regexp Operators. (line 35)
-* double quote (") in shell commands: Read Terminal. (line 25)
* double quote ("), in regexp constants: Computed Regexps. (line 29)
* double quote ("), in shell commands: Quoting. (line 54)
-* down debugger command: Execution Stack. (line 21)
+* down debugger command: Execution Stack. (line 23)
* Drepper, Ulrich: Acknowledgments. (line 52)
+* Duman, Patrice: Acknowledgments. (line 74)
* dump all variables of a program: Options. (line 93)
* dump debugger command: Miscellaneous Debugger Commands.
(line 9)
@@ -32098,10 +32381,10 @@ Index
* dynamically loaded extensions: Dynamic Extensions. (line 6)
* e debugger command (alias for enable): Breakpoint Control. (line 73)
* EBCDIC: Ordinal Functions. (line 45)
-* effective group ID of gawk user: Auto-set. (line 141)
-* effective user ID of gawk user: Auto-set. (line 145)
+* effective group ID of gawk user: Auto-set. (line 142)
+* effective user ID of gawk user: Auto-set. (line 146)
* egrep utility <1>: Egrep Program. (line 6)
-* egrep utility: Bracket Expressions. (line 24)
+* egrep utility: Bracket Expressions. (line 26)
* egrep.awk program: Egrep Program. (line 54)
* elements in arrays, assigning values: Assigning Elements. (line 6)
* elements in arrays, deleting: Delete. (line 6)
@@ -32115,7 +32398,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)
@@ -32127,22 +32410,21 @@ Index
* END pattern, and profiling: Profiling. (line 62)
* END pattern, assert() user-defined function and: Assert Function.
(line 75)
-* END pattern, backslash continuation and: Egrep Program. (line 223)
* END pattern, Boolean patterns and: Expression Patterns. (line 70)
* END pattern, exit statement and: Exit Statement. (line 12)
* END pattern, next/nextfile statements and <1>: Next Statement.
- (line 45)
+ (line 44)
* END pattern, next/nextfile statements and: I/O And BEGIN/END.
- (line 36)
+ (line 37)
* END pattern, operators and: Using BEGIN/END. (line 17)
* END pattern, print statement and: I/O And BEGIN/END. (line 16)
* ENDFILE pattern: BEGINFILE/ENDFILE. (line 6)
* ENDFILE pattern, Boolean patterns and: Expression Patterns. (line 70)
-* endfile() user-defined function: Filetrans Function. (line 62)
-* endgrent() function (C library): Group Functions. (line 213)
-* endgrent() user-defined function: Group Functions. (line 216)
-* endpwent() function (C library): Passwd Functions. (line 210)
-* endpwent() user-defined function: Passwd Functions. (line 213)
+* endfile() user-defined function: Filetrans Function. (line 61)
+* endgrent() function (C library): Group Functions. (line 211)
+* endgrent() user-defined function: Group Functions. (line 214)
+* endpwent() function (C library): Passwd Functions. (line 207)
+* endpwent() user-defined function: Passwd Functions. (line 210)
* English, Steve: Advanced Features. (line 6)
* ENVIRON array: Auto-set. (line 60)
* environment variables used by gawk: Environment Variables.
@@ -32153,14 +32435,14 @@ Index
* equals sign (=), == operator <1>: Precedence. (line 65)
* equals sign (=), == operator: Comparison Operators.
(line 11)
-* EREs (Extended Regular Expressions): Bracket Expressions. (line 24)
+* EREs (Extended Regular Expressions): Bracket Expressions. (line 26)
* ERRNO variable <1>: TCP/IP Networking. (line 54)
* ERRNO variable: Auto-set. (line 82)
* ERRNO variable, with BEGINFILE pattern: BEGINFILE/ENDFILE. (line 26)
* 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: Special FD. (line 19)
* error handling, ERRNO variable and: Auto-set. (line 82)
* error output: Special FD. (line 6)
* escape processing, gsub()/gensub()/sub() functions: Gory Details.
@@ -32176,7 +32458,7 @@ Index
* examining fields: Fields. (line 6)
* exclamation point (!), ! operator <1>: Egrep Program. (line 175)
* exclamation point (!), ! operator <2>: Precedence. (line 52)
-* exclamation point (!), ! operator: Boolean Ops. (line 67)
+* exclamation point (!), ! operator: Boolean Ops. (line 69)
* exclamation point (!), != operator <1>: Precedence. (line 65)
* exclamation point (!), != operator: Comparison Operators.
(line 11)
@@ -32186,8 +32468,8 @@ Index
* exclamation point (!), !~ operator <3>: Comparison Operators.
(line 11)
* exclamation point (!), !~ operator <4>: Regexp Constants. (line 6)
-* exclamation point (!), !~ operator <5>: Computed Regexps. (line 6)
-* exclamation point (!), !~ operator <6>: Case-sensitivity. (line 26)
+* exclamation point (!), !~ operator <5>: Case-sensitivity. (line 26)
+* exclamation point (!), !~ operator <6>: Computed Regexps. (line 6)
* exclamation point (!), !~ operator: Regexp Usage. (line 19)
* exit statement: Exit Statement. (line 6)
* exit status, of gawk: Exit Status. (line 6)
@@ -32195,8 +32477,8 @@ Index
* exit the debugger: Miscellaneous Debugger Commands.
(line 99)
* exp: Numeric Functions. (line 33)
-* expand utility: Very Simple. (line 69)
-* Expat XML parser library: gawkextlib. (line 35)
+* expand utility: Very Simple. (line 72)
+* Expat XML parser library: gawkextlib. (line 31)
* exponent: Numeric Functions. (line 33)
* expressions: Expressions. (line 6)
* expressions, as patterns: Expression Patterns. (line 6)
@@ -32208,14 +32490,14 @@ Index
* expressions, matching, See comparison expressions: Typing and Comparison.
(line 9)
* expressions, selecting: Conditional Exp. (line 6)
-* Extended Regular Expressions (EREs): Bracket Expressions. (line 24)
+* Extended Regular Expressions (EREs): Bracket Expressions. (line 26)
* extension API: Extension API Description.
(line 6)
* extension API informational variables: Extension API Informational Variables.
(line 6)
* extension API version: Extension Versioning.
(line 6)
-* extension API, version number: Auto-set. (line 232)
+* extension API, version number: Auto-set. (line 239)
* extension example: Extension Example. (line 6)
* extension registration: Registration Functions.
(line 6)
@@ -32227,26 +32509,28 @@ 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 48)
+* extensions, common, /dev/stdin special file: Special FD. (line 48)
+* extensions, common, /dev/stdout special file: Special FD. (line 48)
* 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)
* extensions, common, fflush() function: I/O Functions. (line 43)
-* extensions, common, func keyword: Definition Syntax. (line 89)
+* extensions, common, func keyword: Definition Syntax. (line 93)
* extensions, common, length() applied to an array: String Functions.
- (line 197)
+ (line 200)
* extensions, common, RS as a regexp: gawk split records. (line 6)
* extensions, common, single character fields: Single Character Fields.
(line 6)
* extensions, in gawk, not in POSIX awk: POSIX/GNU. (line 6)
+* extensions, loading, @load directive: Loading Shared Libraries.
+ (line 8)
* extensions, mawk: Common Extensions. (line 6)
* extensions, where to find: gawkextlib. (line 6)
* extract.awk program: Extract Program. (line 79)
* extraction, of marked strings (internationalization): String Extraction.
(line 6)
-* f debugger command (alias for frame): Execution Stack. (line 25)
+* f debugger command (alias for frame): Execution Stack. (line 27)
* false, logical: Truth Values. (line 6)
* FDL (Free Documentation License): GNU Free Documentation License.
(line 7)
@@ -32274,7 +32558,7 @@ Index
(line 6)
* field separators, regular expressions as: Field Separators. (line 51)
* field separators, See Also OFS: Changing Fields. (line 64)
-* field separators, spaces as: Cut Program. (line 109)
+* field separators, spaces as: Cut Program. (line 103)
* fields <1>: Basic High Level. (line 73)
* fields <2>: Fields. (line 6)
* fields: Reading Files. (line 14)
@@ -32291,9 +32575,10 @@ Index
* FIELDWIDTHS variable <1>: User-modified. (line 37)
* FIELDWIDTHS variable: Constant Size. (line 23)
* file descriptors: Special FD. (line 6)
+* 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 48)
* FILENAME variable <1>: Auto-set. (line 98)
* FILENAME variable: Reading Files. (line 6)
* FILENAME variable, getline, setting with: Getline Notes. (line 19)
@@ -32301,12 +32586,12 @@ Index
* files, .gmo: Explaining gettext. (line 42)
* files, .gmo, specifying directory of <1>: Programmer i18n. (line 47)
* files, .gmo, specifying directory of: Explaining gettext. (line 54)
-* files, .mo, converting from .po: I18N Example. (line 63)
+* files, .mo, converting from .po: I18N Example. (line 64)
* files, .po <1>: Translator i18n. (line 6)
* files, .po: Explaining gettext. (line 37)
-* files, .po, converting to .mo: I18N Example. (line 63)
+* files, .po, converting to .mo: I18N Example. (line 64)
* files, .pot: Explaining gettext. (line 31)
-* files, /dev/... special files: Special FD. (line 46)
+* files, /dev/... special files: Special FD. (line 48)
* files, /inet/... (gawk): TCP/IP Networking. (line 6)
* files, /inet4/... (gawk): TCP/IP Networking. (line 6)
* files, /inet6/... (gawk): TCP/IP Networking. (line 6)
@@ -32324,12 +32609,12 @@ Index
* files, managing, data file boundaries: Filetrans Function. (line 6)
* files, message object: Explaining gettext. (line 42)
* files, message object, converting from portable object files: I18N Example.
- (line 63)
+ (line 64)
* files, message object, specifying directory of <1>: Programmer i18n.
(line 47)
* files, message object, specifying directory of: Explaining gettext.
(line 54)
-* files, multiple passes over: Other Arguments. (line 49)
+* 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)
@@ -32338,14 +32623,14 @@ Index
* files, portable object: Explaining gettext. (line 37)
* files, portable object template: Explaining gettext. (line 31)
* files, portable object, converting to message object files: I18N Example.
- (line 63)
+ (line 64)
* files, portable object, generating: Options. (line 147)
* files, processing, ARGIND variable and: Auto-set. (line 51)
* files, reading: Rewind Function. (line 6)
* files, reading, multiline records: Multiple Line. (line 6)
* files, searching for regular expressions: Egrep Program. (line 6)
* files, skipping: File Checking. (line 6)
-* files, source, search path for: Programs Exercises. (line 63)
+* files, source, search path for: Programs Exercises. (line 70)
* files, splitting: Split Program. (line 6)
* files, Texinfo, extracting programs from: Extract Program. (line 6)
* find substring in string: String Functions. (line 155)
@@ -32355,7 +32640,7 @@ Index
* Fish, Fred: Contributors. (line 50)
* fixed-width data: Constant Size. (line 10)
* flag variables <1>: Tee Program. (line 20)
-* flag variables: Boolean Ops. (line 67)
+* flag variables: Boolean Ops. (line 69)
* floating-point, numbers, arbitrary precision: Arbitrary Precision Arithmetic.
(line 6)
* floating-point, VAX/VMS: VMS Running. (line 51)
@@ -32364,7 +32649,7 @@ Index
(line 12)
* FNR variable <1>: Auto-set. (line 107)
* FNR variable: Records. (line 6)
-* FNR variable, changing: Auto-set. (line 309)
+* FNR variable, changing: Auto-set. (line 321)
* for statement: For Statement. (line 6)
* for statement, looping over arrays: Scanning an Array. (line 20)
* fork() extension function: Extension Sample Fork.
@@ -32378,7 +32663,7 @@ Index
* format time string: Time Functions. (line 48)
* formats, numeric output: OFMT. (line 6)
* formatting output: Printf. (line 6)
-* formatting strings: String Functions. (line 381)
+* formatting strings: String Functions. (line 382)
* forward slash (/) to enclose regular expressions: Regexp. (line 10)
* forward slash (/), / operator: Precedence. (line 55)
* forward slash (/), /= operator <1>: Precedence. (line 95)
@@ -32389,7 +32674,7 @@ Index
* FPAT variable <1>: User-modified. (line 43)
* FPAT variable: Splitting By Content.
(line 27)
-* frame debugger command: Execution Stack. (line 25)
+* frame debugger command: Execution Stack. (line 27)
* Free Documentation License (FDL): GNU Free Documentation License.
(line 7)
* Free Software Foundation (FSF) <1>: Glossary. (line 296)
@@ -32401,9 +32686,9 @@ Index
* FS variable, --field-separator option and: Options. (line 21)
* FS variable, as null string: Single Character Fields.
(line 20)
-* FS variable, as TAB character: Options. (line 264)
+* FS variable, as TAB character: Options. (line 266)
* FS variable, changing value of: Field Separators. (line 35)
-* FS variable, running awk programs and: Cut Program. (line 68)
+* FS variable, running awk programs and: Cut Program. (line 63)
* FS variable, setting from command line: Command Line Field Separator.
(line 6)
* FS, containing ^: Regexp Field Splitting.
@@ -32417,6 +32702,7 @@ Index
* FUNCTAB array: Auto-set. (line 123)
* function calls: Function Calls. (line 6)
* function calls, indirect: Indirect Calls. (line 6)
+* function calls, indirect, @-notation for: Indirect Calls. (line 47)
* function definition example: Function Example. (line 6)
* function pointers: Indirect Calls. (line 6)
* functions, arrays as parameters to: Pass By Value/Reference.
@@ -32424,10 +32710,10 @@ Index
* functions, built-in <1>: Functions. (line 6)
* functions, built-in: Function Calls. (line 10)
* functions, built-in, evaluation order: Calling Built-in. (line 30)
-* functions, defining: Definition Syntax. (line 6)
+* functions, defining: Definition Syntax. (line 9)
* functions, library: Library Functions. (line 6)
* functions, library, assertions: Assert Function. (line 6)
-* functions, library, associative arrays and: Library Names. (line 57)
+* functions, library, associative arrays and: Library Names. (line 58)
* functions, library, C library: Getopt Function. (line 6)
* functions, library, character values as numbers: Ordinal Functions.
(line 6)
@@ -32447,9 +32733,8 @@ Index
* functions, library, rounding numbers: Round Function. (line 6)
* functions, library, user database, reading: Passwd Functions.
(line 6)
-* functions, names of <1>: Definition Syntax. (line 20)
-* functions, names of: Arrays. (line 18)
-* functions, recursive: Definition Syntax. (line 79)
+* functions, names of: Definition Syntax. (line 23)
+* functions, recursive: Definition Syntax. (line 83)
* functions, string-translation: I18N Functions. (line 6)
* functions, undefined: Pass By Value/Reference.
(line 71)
@@ -32460,23 +32745,20 @@ Index
* functions, user-defined, next/nextfile statements and <1>: Nextfile Statement.
(line 47)
* functions, user-defined, next/nextfile statements and: Next Statement.
- (line 45)
-* G-d: Acknowledgments. (line 92)
+ (line 44)
+* G-d: Acknowledgments. (line 94)
* Garfinkle, Scott: Contributors. (line 34)
* gawk program, dynamic profiling: Profiling. (line 179)
-* gawk version: Auto-set. (line 207)
-* gawk, ARGIND variable in: Other Arguments. (line 12)
+* gawk version: Auto-set. (line 214)
+* 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)
+* gawk, bitwise operations in: Bitwise Functions. (line 40)
* gawk, break statement in: Break Statement. (line 51)
-* gawk, built-in variables and: Built-in Variables. (line 14)
-* gawk, character classes and: Bracket Expressions. (line 98)
+* gawk, character classes and: Bracket Expressions. (line 100)
* gawk, coding style in: Adding Code. (line 39)
* gawk, command-line options, and regular expressions: GNU Regexp Operators.
(line 70)
-* gawk, comparison operators and: Comparison Operators.
- (line 50)
* gawk, configuring: Configuration Philosophy.
(line 6)
* gawk, configuring, options: Additional Configuration Options.
@@ -32488,10 +32770,10 @@ Index
* gawk, ERRNO variable in <2>: Auto-set. (line 82)
* 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 252)
+* gawk, escape sequences: Escape Sequences. (line 132)
+* gawk, extensions, disabling: Options. (line 254)
* gawk, features, adding: Adding Code. (line 6)
* gawk, features, advanced: Advanced Features. (line 6)
* gawk, field separators and: User-modified. (line 71)
@@ -32507,8 +32789,8 @@ Index
* gawk, hexadecimal numbers and: Nondecimal-numbers. (line 42)
* gawk, IGNORECASE variable in <1>: Array Sorting Functions.
(line 83)
-* gawk, IGNORECASE variable in <2>: String Functions. (line 58)
-* gawk, IGNORECASE variable in <3>: Array Intro. (line 92)
+* gawk, IGNORECASE variable in <2>: String Functions. (line 57)
+* gawk, IGNORECASE variable in <3>: Array Intro. (line 94)
* gawk, IGNORECASE variable in <4>: User-modified. (line 76)
* gawk, IGNORECASE variable in: Case-sensitivity. (line 26)
* gawk, implementation issues: Notes. (line 6)
@@ -32516,13 +32798,13 @@ 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)
* gawk, interpreter, adding code to: Using Internal File Ops.
(line 6)
-* gawk, interval expressions and: Regexp Operators. (line 140)
+* gawk, interval expressions and: Regexp Operators. (line 139)
* gawk, line continuation in: Conditional Exp. (line 34)
* gawk, LINT variable in: User-modified. (line 88)
* gawk, list of contributors to: Contributors. (line 6)
@@ -32531,28 +32813,29 @@ Index
* gawk, newlines in: Statements/Lines. (line 12)
* gawk, octal numbers and: Nondecimal-numbers. (line 42)
* gawk, OS/2 version of: PC Using. (line 16)
+* gawk, predefined variables and: Built-in Variables. (line 14)
* gawk, PROCINFO array in <1>: Two-way I/O. (line 99)
* gawk, PROCINFO array in <2>: Time Functions. (line 47)
-* gawk, PROCINFO array in: Auto-set. (line 136)
+* gawk, PROCINFO array in: Auto-set. (line 137)
* gawk, regexp constants and: Using Constant Regexps.
(line 28)
* gawk, regular expressions, case sensitivity: Case-sensitivity.
(line 26)
* gawk, regular expressions, operators: GNU Regexp Operators.
(line 6)
-* gawk, regular expressions, precedence: Regexp Operators. (line 162)
-* gawk, RT variable in <1>: Auto-set. (line 265)
+* gawk, regular expressions, precedence: Regexp Operators. (line 161)
+* gawk, RT variable in <1>: Auto-set. (line 272)
* 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)
* gawk, string-translation functions: I18N Functions. (line 6)
-* gawk, SYMTAB array in: Auto-set. (line 269)
-* gawk, TEXTDOMAIN variable in: User-modified. (line 152)
+* gawk, SYMTAB array in: Auto-set. (line 276)
+* gawk, TEXTDOMAIN variable in: User-modified. (line 151)
* gawk, timestamps: Time Functions. (line 6)
* gawk, uses for: Preface. (line 34)
-* gawk, versions of, information about, printing: Options. (line 298)
+* gawk, versions of, information about, printing: Options. (line 300)
* gawk, VMS version of: VMS Installation. (line 6)
* gawk, word-boundary operator: GNU Regexp Operators.
(line 63)
@@ -32568,12 +32851,12 @@ Index
* getaddrinfo() function (C library): TCP/IP Networking. (line 38)
* getgrent() function (C library): Group Functions. (line 6)
* getgrent() user-defined function: Group Functions. (line 6)
-* getgrgid() function (C library): Group Functions. (line 184)
-* getgrgid() user-defined function: Group Functions. (line 187)
-* getgrnam() function (C library): Group Functions. (line 173)
-* getgrnam() user-defined function: Group Functions. (line 178)
-* getgruser() function (C library): Group Functions. (line 193)
-* getgruser() function, user-defined: Group Functions. (line 196)
+* getgrgid() function (C library): Group Functions. (line 182)
+* getgrgid() user-defined function: Group Functions. (line 185)
+* getgrnam() function (C library): Group Functions. (line 171)
+* getgrnam() user-defined function: Group Functions. (line 176)
+* getgruser() function (C library): Group Functions. (line 191)
+* getgruser() function, user-defined: Group Functions. (line 194)
* getline command: Reading Files. (line 20)
* getline command, _gr_init() user-defined function: Group Functions.
(line 83)
@@ -32597,10 +32880,10 @@ Index
* getopt() user-defined function: Getopt Function. (line 108)
* getpwent() function (C library): Passwd Functions. (line 16)
* getpwent() user-defined function: Passwd Functions. (line 16)
-* getpwnam() function (C library): Passwd Functions. (line 177)
-* getpwnam() user-defined function: Passwd Functions. (line 182)
-* getpwuid() function (C library): Passwd Functions. (line 188)
-* getpwuid() user-defined function: Passwd Functions. (line 192)
+* getpwnam() function (C library): Passwd Functions. (line 174)
+* getpwnam() user-defined function: Passwd Functions. (line 179)
+* getpwuid() function (C library): Passwd Functions. (line 185)
+* getpwuid() user-defined function: Passwd Functions. (line 189)
* gettext library: Explaining gettext. (line 6)
* gettext library, locale categories: Explaining gettext. (line 81)
* gettext() function (C library): Explaining gettext. (line 63)
@@ -32610,7 +32893,7 @@ Index
* git utility <2>: Accessing The Source.
(line 10)
* git utility <3>: Other Versions. (line 29)
-* git utility: gawkextlib. (line 29)
+* git utility: gawkextlib. (line 25)
* Git, use of for gawk source code: Derived Files. (line 6)
* GNITS mailing list: Acknowledgments. (line 52)
* GNU awk, See gawk: Preface. (line 51)
@@ -32634,12 +32917,12 @@ Index
* Grigera, Juan: Contributors. (line 57)
* group database, reading: Group Functions. (line 6)
* group file: Group Functions. (line 6)
-* group ID of gawk user: Auto-set. (line 180)
+* group ID of gawk user: Auto-set. (line 187)
* groups, information about: Group Functions. (line 6)
* gsub <1>: String Functions. (line 139)
* gsub: Using Constant Regexps.
(line 43)
-* gsub() function, arguments of: String Functions. (line 460)
+* gsub() function, arguments of: String Functions. (line 461)
* gsub() function, escape processing: Gory Details. (line 6)
* h debugger command (alias for help): Miscellaneous Debugger Commands.
(line 66)
@@ -32674,7 +32957,7 @@ Index
* ignore breakpoint: Breakpoint Control. (line 87)
* ignore debugger command: Breakpoint Control. (line 87)
* IGNORECASE variable: User-modified. (line 76)
-* IGNORECASE variable, and array indices: Array Intro. (line 92)
+* IGNORECASE variable, and array indices: Array Intro. (line 94)
* IGNORECASE variable, and array sorting functions: Array Sorting Functions.
(line 83)
* IGNORECASE variable, in example programs: Library Functions.
@@ -32685,9 +32968,9 @@ 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 <1>: For Statement. (line 76)
* in operator <2>: Precedence. (line 83)
* in operator: Comparison Operators.
(line 11)
@@ -32697,10 +32980,12 @@ Index
* in operator, testing if array element exists: Reference to Elements.
(line 38)
* in operator, use in loops: Scanning an Array. (line 17)
+* including files, @include directive: Include Files. (line 8)
* increment operators: Increment Ops. (line 6)
* index: String Functions. (line 155)
* indexing arrays: Array Intro. (line 50)
* indirect function calls: Indirect Calls. (line 6)
+* indirect function calls, @-notation: Indirect Calls. (line 47)
* infinite precision: Arbitrary Precision Arithmetic.
(line 6)
* info debugger command: Debugger Info. (line 13)
@@ -32714,9 +32999,9 @@ 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 19)
+* input files, variable assignments and: Other Arguments. (line 26)
* input pipeline: Getline/Pipe. (line 9)
-* input record, length of: String Functions. (line 174)
+* input record, length of: String Functions. (line 177)
* input redirection: Getline/File. (line 6)
* input, data, nondecimal: Nondecimal Data. (line 6)
* input, explicit: Getline. (line 6)
@@ -32740,14 +33025,14 @@ Index
* integers, arbitrary precision: Arbitrary Precision Integers.
(line 6)
* integers, unsigned: Computer Arithmetic. (line 41)
-* interacting with other programs: I/O Functions. (line 75)
+* interacting with other programs: I/O Functions. (line 74)
* internationalization <1>: I18N and L10N. (line 6)
* internationalization: I18N Functions. (line 6)
* internationalization, localization <1>: Internationalization.
(line 13)
-* internationalization, localization: User-modified. (line 152)
+* internationalization, localization: User-modified. (line 151)
* internationalization, localization, character classes: Bracket Expressions.
- (line 98)
+ (line 100)
* internationalization, localization, gawk and: Internationalization.
(line 13)
* internationalization, localization, locale categories: Explaining gettext.
@@ -32759,9 +33044,9 @@ Index
* internationalizing a program: Explaining gettext. (line 6)
* interpreted programs <1>: Glossary. (line 356)
* interpreted programs: Basic High Level. (line 15)
-* interval expressions, regexp operator: Regexp Operators. (line 117)
+* interval expressions, regexp operator: Regexp Operators. (line 116)
* inventory-shipped file: Sample Data Files. (line 32)
-* invoke shell command: I/O Functions. (line 75)
+* invoke shell command: I/O Functions. (line 74)
* isarray: Type Functions. (line 11)
* ISO: Glossary. (line 367)
* ISO 8859-1: Glossary. (line 133)
@@ -32787,7 +33072,7 @@ Index
* Kernighan, Brian <6>: Library Functions. (line 12)
* Kernighan, Brian <7>: Concatenation. (line 6)
* Kernighan, Brian <8>: Getline/Pipe. (line 6)
-* Kernighan, Brian <9>: Acknowledgments. (line 76)
+* Kernighan, Brian <9>: Acknowledgments. (line 78)
* Kernighan, Brian <10>: Conventions. (line 38)
* Kernighan, Brian: History. (line 17)
* kill command, dynamic profiling: Profiling. (line 188)
@@ -32803,7 +33088,7 @@ Index
* LC_CTYPE locale category: Explaining gettext. (line 98)
* LC_MESSAGES locale category: Explaining gettext. (line 88)
* LC_MESSAGES locale category, bindtextdomain() function (gawk): Programmer i18n.
- (line 99)
+ (line 101)
* LC_MONETARY locale category: Explaining gettext. (line 104)
* LC_NUMERIC locale category: Explaining gettext. (line 108)
* LC_TIME locale category: Explaining gettext. (line 112)
@@ -32814,19 +33099,19 @@ Index
* left angle bracket (<), <= operator <1>: Precedence. (line 65)
* left angle bracket (<), <= operator: Comparison Operators.
(line 11)
-* left shift: Bitwise Functions. (line 46)
+* left shift: Bitwise Functions. (line 47)
* left shift, bitwise: Bitwise Functions. (line 32)
* leftmost longest match: Multiple Line. (line 26)
-* length: String Functions. (line 167)
-* length of input record: String Functions. (line 174)
-* length of string: String Functions. (line 167)
+* length: String Functions. (line 170)
+* length of input record: String Functions. (line 177)
+* length of string: String Functions. (line 170)
* Lesser General Public License (LGPL): Glossary. (line 396)
* LGPL (Lesser General Public License): Glossary. (line 396)
* libmawk: Other Versions. (line 121)
* libraries of awk functions: Library Functions. (line 6)
* libraries of awk functions, assertions: Assert Function. (line 6)
* libraries of awk functions, associative arrays and: Library Names.
- (line 57)
+ (line 58)
* libraries of awk functions, character values as numbers: Ordinal Functions.
(line 6)
* libraries of awk functions, command-line options: Getopt Function.
@@ -32846,7 +33131,7 @@ Index
* libraries of awk functions, user database, reading: Passwd Functions.
(line 6)
* line breaks: Statements/Lines. (line 6)
-* line continuations: Boolean Ops. (line 62)
+* line continuations: Boolean Ops. (line 64)
* line continuations, gawk: Conditional Exp. (line 34)
* line continuations, in print statement: Print Examples. (line 76)
* line continuations, with C shell: More Complex. (line 30)
@@ -32862,7 +33147,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 336)
+ (line 339)
* lint checking, undefined functions: Pass By Value/Reference.
(line 88)
* LINT variable: User-modified. (line 88)
@@ -32873,10 +33158,12 @@ Index
* list debugger command: Miscellaneous Debugger Commands.
(line 72)
* list function definitions, in debugger: Debugger Info. (line 30)
+* loading extensions, @load directive: Loading Shared Libraries.
+ (line 8)
* loading, extensions: Options. (line 173)
* local variables, in a function: Variable Scope. (line 6)
* locale categories: Explaining gettext. (line 81)
-* locale decimal point character: Options. (line 268)
+* locale decimal point character: Options. (line 270)
* locale, definition of: Locales. (line 6)
* localization: I18N and L10N. (line 6)
* localization, See internationalization, localization: I18N and L10N.
@@ -32890,7 +33177,7 @@ Index
* long options: Command Line. (line 13)
* loops: While Statement. (line 6)
* loops, break statement and: Break Statement. (line 6)
-* loops, continue statements and: For Statement. (line 64)
+* loops, continue statements and: For Statement. (line 65)
* loops, count for header, in a profile: Profiling. (line 131)
* loops, do-while: Do Statement. (line 6)
* loops, exiting: Break Statement. (line 6)
@@ -32899,68 +33186,66 @@ Index
* loops, See Also while statement: While Statement. (line 6)
* loops, while: While Statement. (line 6)
* ls utility: More Complex. (line 15)
-* lshift: Bitwise Functions. (line 46)
+* lshift: Bitwise Functions. (line 47)
* lvalues/rvalues: Assignment Ops. (line 32)
* mail-list file: Sample Data Files. (line 6)
* mailing labels, printing: Labels Program. (line 6)
* mailing list, GNITS: Acknowledgments. (line 52)
-* Malmberg, John <1>: Bugs. (line 71)
+* Malmberg, John <1>: Bugs. (line 72)
* Malmberg, John: Acknowledgments. (line 60)
+* Malmberg, John E.: Contributors. (line 137)
* mark parity: Ordinal Functions. (line 45)
* marked string extraction (internationalization): String Extraction.
(line 6)
* marked strings, extracting: String Extraction. (line 6)
* Marx, Groucho: Increment Ops. (line 60)
-* match: String Functions. (line 207)
-* match regexp in string: String Functions. (line 207)
+* match: String Functions. (line 210)
+* match regexp in string: String Functions. (line 210)
* match() function, RSTART/RLENGTH variables: String Functions.
- (line 224)
+ (line 227)
* matching, expressions, See comparison expressions: Typing and Comparison.
(line 9)
* matching, leftmost longest: Multiple Line. (line 26)
-* matching, null strings: Gory Details. (line 143)
+* matching, null strings: String Functions. (line 535)
* mawk utility <1>: Other Versions. (line 44)
* mawk utility <2>: Nextfile Statement. (line 47)
* mawk utility <3>: Concatenation. (line 36)
* mawk utility <4>: Getline/Pipe. (line 62)
-* mawk utility: Escape Sequences. (line 130)
-* maximum precision supported by MPFR library: Auto-set. (line 221)
+* mawk utility: Escape Sequences. (line 132)
+* maximum precision supported by MPFR library: Auto-set. (line 228)
* McIlroy, Doug: Glossary. (line 149)
* McPhee, Patrick: Contributors. (line 100)
* message object files: Explaining gettext. (line 42)
* message object files, converting from portable object files: I18N Example.
- (line 63)
+ (line 64)
* message object files, specifying directory of <1>: Programmer i18n.
(line 47)
* message object files, specifying directory of: Explaining gettext.
(line 54)
* messages from extensions: Printing Messages. (line 6)
* metacharacters in regular expressions: Regexp Operators. (line 6)
-* metacharacters, escape sequences for: Escape Sequences. (line 136)
-* minimum precision supported by MPFR library: Auto-set. (line 224)
+* metacharacters, escape sequences for: Escape Sequences. (line 138)
+* minimum precision supported by MPFR library: Auto-set. (line 231)
* mktime: Time Functions. (line 25)
* modifiers, in format specifiers: Format Modifiers. (line 6)
* monetary information, localization: Explaining gettext. (line 104)
* Moore, Duncan: Getline Notes. (line 40)
-* msgfmt utility: I18N Example. (line 63)
+* msgfmt utility: I18N Example. (line 64)
* multiple precision: Arbitrary Precision Arithmetic.
(line 6)
* multiple-line records: Multiple Line. (line 6)
* n debugger command (alias for next): Debugger Execution Control.
(line 43)
-* names, arrays/variables <1>: Library Names. (line 6)
-* names, arrays/variables: Arrays. (line 18)
+* names, arrays/variables: Library Names. (line 6)
* names, functions <1>: Library Names. (line 6)
-* names, functions: Definition Syntax. (line 20)
-* namespace issues <1>: Library Names. (line 6)
-* namespace issues: Arrays. (line 18)
-* namespace issues, functions: Definition Syntax. (line 20)
-* nawk utility: Names. (line 10)
+* names, functions: Definition Syntax. (line 23)
+* namespace issues: Library Names. (line 6)
+* namespace issues, functions: Definition Syntax. (line 23)
* NetBSD: Glossary. (line 611)
* networks, programming: TCP/IP Networking. (line 6)
* networks, support for: Special Network. (line 6)
-* newlines <1>: Boolean Ops. (line 67)
-* newlines <2>: Options. (line 258)
+* newlines <1>: Boolean Ops. (line 69)
+* newlines <2>: Options. (line 260)
* newlines: Statements/Lines. (line 6)
* newlines, as field separators: Default Field Splitting.
(line 6)
@@ -32975,14 +33260,14 @@ Index
(line 43)
* next file statement: Feature History. (line 169)
* next statement <1>: Next Statement. (line 6)
-* next statement: Boolean Ops. (line 85)
-* next statement, BEGIN/END patterns and: I/O And BEGIN/END. (line 36)
+* next statement: Boolean Ops. (line 95)
+* next statement, BEGIN/END patterns and: I/O And BEGIN/END. (line 37)
* next statement, BEGINFILE/ENDFILE patterns and: BEGINFILE/ENDFILE.
(line 49)
-* next statement, user-defined functions and: Next Statement. (line 45)
+* next statement, user-defined functions and: Next Statement. (line 44)
* nextfile statement: Nextfile Statement. (line 6)
* nextfile statement, BEGIN/END patterns and: I/O And BEGIN/END.
- (line 36)
+ (line 37)
* nextfile statement, BEGINFILE/ENDFILE patterns and: BEGINFILE/ENDFILE.
(line 26)
* nextfile statement, user-defined functions and: Nextfile Statement.
@@ -32998,23 +33283,23 @@ Index
* non-existent array elements: Reference to Elements.
(line 23)
* not Boolean-logic operator: Boolean Ops. (line 6)
-* NR variable <1>: Auto-set. (line 131)
+* NR variable <1>: Auto-set. (line 132)
* NR variable: Records. (line 6)
-* NR variable, changing: Auto-set. (line 309)
+* NR variable, changing: Auto-set. (line 321)
* null strings <1>: Basic Data Typing. (line 26)
* 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)
* null strings, converting numbers to strings: Strings And Numbers.
(line 21)
-* null strings, matching: Gory Details. (line 143)
-* number as string of bits: Bitwise Functions. (line 109)
-* number of array elements: String Functions. (line 197)
+* null strings, matching: String Functions. (line 535)
+* number as string of bits: Bitwise Functions. (line 110)
+* number of array elements: String Functions. (line 200)
* number sign (#), #! (executable scripts): Executable Scripts.
(line 6)
* number sign (#), commenting: Comments. (line 6)
@@ -33023,7 +33308,7 @@ Index
* numbers, as values of characters: Ordinal Functions. (line 6)
* numbers, Cliff random: Cliff Random Function.
(line 6)
-* numbers, converting <1>: Bitwise Functions. (line 109)
+* numbers, converting <1>: Bitwise Functions. (line 110)
* numbers, converting: Strings And Numbers. (line 6)
* numbers, converting, to strings: User-modified. (line 30)
* numbers, hexadecimal: Nondecimal-numbers. (line 6)
@@ -33034,7 +33319,6 @@ Index
* numeric, output format: OFMT. (line 6)
* numeric, strings: Variable Typing. (line 6)
* o debugger command (alias for option): Debugger Info. (line 57)
-* oawk utility: Names. (line 10)
* obsolete features: Obsolete. (line 6)
* octal numbers: Nondecimal-numbers. (line 6)
* octal values, enabling interpretation of: Options. (line 211)
@@ -33042,7 +33326,7 @@ Index
* OFMT variable <2>: Strings And Numbers. (line 57)
* OFMT variable: OFMT. (line 15)
* OFMT variable, POSIX awk and: OFMT. (line 27)
-* OFS variable <1>: User-modified. (line 114)
+* OFS variable <1>: User-modified. (line 113)
* OFS variable <2>: Output Separators. (line 6)
* OFS variable: Changing Fields. (line 64)
* OpenBSD: Glossary. (line 611)
@@ -33072,7 +33356,7 @@ Index
* operators, precedence: Increment Ops. (line 60)
* operators, relational, See operators, comparison: Typing and Comparison.
(line 9)
-* operators, short-circuit: Boolean Ops. (line 57)
+* operators, short-circuit: Boolean Ops. (line 59)
* operators, string: Concatenation. (line 8)
* operators, string-matching: Regexp Usage. (line 19)
* operators, string-matching, for buffers: GNU Regexp Operators.
@@ -33088,14 +33372,14 @@ Index
* options, long <1>: Options. (line 6)
* options, long: Command Line. (line 13)
* options, printing list of: Options. (line 154)
-* or: Bitwise Functions. (line 49)
+* or: Bitwise Functions. (line 50)
* OR bitwise operation: Bitwise Functions. (line 6)
* or Boolean-logic operator: Boolean Ops. (line 6)
* ord() extension function: Extension Sample Ord.
(line 12)
* ord() user-defined function: Ordinal Functions. (line 16)
* order of evaluation, concatenation: Concatenation. (line 41)
-* ORS variable <1>: User-modified. (line 119)
+* ORS variable <1>: User-modified. (line 118)
* ORS variable: Output Separators. (line 20)
* output field separator, See OFS variable: Changing Fields. (line 64)
* output record separator, See ORS variable: Output Separators.
@@ -33115,11 +33399,11 @@ Index
* p debugger command (alias for print): Viewing And Changing Data.
(line 36)
* Papadopoulos, Panos: Contributors. (line 128)
-* parent process ID of gawk process: Auto-set. (line 189)
+* parent process ID of gawk process: Auto-set. (line 196)
* parentheses (), in a profile: Profiling. (line 146)
-* parentheses (), regexp operator: Regexp Operators. (line 80)
+* parentheses (), regexp operator: Regexp Operators. (line 81)
* password file: Passwd Functions. (line 16)
-* patsplit: String Functions. (line 294)
+* patsplit: String Functions. (line 296)
* patterns: Patterns and Actions.
(line 6)
* patterns, comparison expressions as: Expression Patterns. (line 14)
@@ -33146,7 +33430,7 @@ Index
(line 6)
* pipe, input: Getline/Pipe. (line 9)
* pipe, output: Redirection. (line 57)
-* Pitts, Dave <1>: Bugs. (line 71)
+* Pitts, Dave <1>: Bugs. (line 72)
* Pitts, Dave: Acknowledgments. (line 60)
* Plauger, P.J.: Library Functions. (line 12)
* plug-in: Extension Intro. (line 6)
@@ -33155,39 +33439,39 @@ Index
* plus sign (+), ++ operator: Increment Ops. (line 11)
* plus sign (+), += operator <1>: Precedence. (line 95)
* plus sign (+), += operator: Assignment Ops. (line 82)
-* plus sign (+), regexp operator: Regexp Operators. (line 103)
+* plus sign (+), regexp operator: Regexp Operators. (line 105)
* pointers to functions: Indirect Calls. (line 6)
-* portability: Escape Sequences. (line 100)
+* portability: Escape Sequences. (line 102)
* portability, #! (executable scripts): Executable Scripts. (line 33)
* portability, ** operator and: Arithmetic Ops. (line 81)
* portability, **= operator and: Assignment Ops. (line 143)
-* portability, ARGV variable: Executable Scripts. (line 42)
+* portability, ARGV variable: Executable Scripts. (line 59)
* portability, backslash continuation and: Statements/Lines. (line 30)
* portability, backslash in escape sequences: Escape Sequences.
- (line 118)
+ (line 120)
* portability, close() function and: Close Files And Pipes.
(line 81)
* portability, data files as single record: gawk split records.
(line 65)
* portability, deleting array elements: Delete. (line 56)
* portability, example programs: Library Functions. (line 42)
-* portability, functions, defining: Definition Syntax. (line 105)
+* portability, functions, defining: Definition Syntax. (line 109)
* portability, gawk: New Ports. (line 6)
* portability, gettext library and: Explaining gettext. (line 11)
* portability, internationalization and: I18N Portability. (line 6)
-* portability, length() function: String Functions. (line 176)
+* portability, length() function: String Functions. (line 179)
* portability, new awk vs. old awk: Strings And Numbers. (line 57)
* portability, next statement in user-defined functions: Pass By Value/Reference.
(line 91)
* 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 356)
-* portability, substr() function: String Functions. (line 510)
+* portability, POSIXLY_CORRECT environment variable: Options. (line 359)
+* portability, substr() function: String Functions. (line 511)
* portable object files <1>: Translator i18n. (line 6)
* portable object files: Explaining gettext. (line 37)
* portable object files, converting to message object files: I18N Example.
- (line 63)
+ (line 64)
* portable object files, generating: Options. (line 147)
* portable object template files: Explaining gettext. (line 31)
* porting gawk: New Ports. (line 6)
@@ -33203,11 +33487,11 @@ Index
* POSIX awk, < operator and: Getline/File. (line 26)
* POSIX awk, arithmetic operators and: Arithmetic Ops. (line 30)
* POSIX awk, backslashes in string constants: Escape Sequences.
- (line 118)
+ (line 120)
* POSIX awk, BEGIN/END patterns: I/O And BEGIN/END. (line 16)
-* POSIX awk, bracket expressions and: Bracket Expressions. (line 24)
+* POSIX awk, bracket expressions and: Bracket Expressions. (line 26)
* POSIX awk, bracket expressions and, character classes: Bracket Expressions.
- (line 30)
+ (line 32)
* POSIX awk, break statement and: Break Statement. (line 51)
* POSIX awk, changes in awk versions: POSIX. (line 6)
* POSIX awk, continue statement and: Continue Statement. (line 44)
@@ -33217,29 +33501,33 @@ Index
(line 40)
* POSIX awk, field separators and: Fields. (line 6)
* POSIX awk, FS variable and: User-modified. (line 60)
-* POSIX awk, function keyword in: Definition Syntax. (line 89)
+* POSIX awk, function keyword in: Definition Syntax. (line 93)
* POSIX awk, functions and, gsub()/sub(): Gory Details. (line 90)
-* POSIX awk, functions and, length(): String Functions. (line 176)
+* POSIX awk, functions and, length(): String Functions. (line 179)
* POSIX awk, GNU long options and: Options. (line 15)
-* POSIX awk, interval expressions in: Regexp Operators. (line 136)
-* POSIX awk, next/nextfile statements and: Next Statement. (line 45)
+* POSIX awk, interval expressions in: Regexp Operators. (line 135)
+* POSIX awk, next/nextfile statements and: Next Statement. (line 44)
* POSIX awk, numeric strings and: Variable Typing. (line 6)
* POSIX awk, OFMT variable and <1>: Strings And Numbers. (line 57)
* POSIX awk, OFMT variable and: OFMT. (line 27)
* POSIX awk, period (.), using: Regexp Operators. (line 51)
-* POSIX awk, printf format strings and: Format Modifiers. (line 159)
-* POSIX awk, regular expressions and: Regexp Operators. (line 162)
+* POSIX awk, 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)
-* POSIX mode: Options. (line 252)
+* POSIX mode: Options. (line 254)
* 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 336)
-* PREC variable: User-modified. (line 124)
+* POSIXLY_CORRECT environment variable: Options. (line 339)
+* PREC variable: User-modified. (line 123)
* precedence <1>: Precedence. (line 6)
* precedence: Increment Ops. (line 60)
-* precedence, regexp operators: Regexp Operators. (line 157)
+* precedence, regexp operators: Regexp Operators. (line 156)
+* predefined variables: Built-in Variables. (line 6)
+* predefined variables, -v option, setting with: Options. (line 40)
+* predefined variables, conveying information: Auto-set. (line 6)
+* predefined variables, user-modifiable: User-modified. (line 6)
* print debugger command: Viewing And Changing Data.
(line 36)
* print statement: Printing. (line 16)
@@ -33247,7 +33535,7 @@ Index
* print statement, commas, omitting: Print Examples. (line 31)
* print statement, I/O operators in: Precedence. (line 71)
* print statement, line continuations and: Print Examples. (line 76)
-* print statement, OFMT variable and: User-modified. (line 114)
+* print statement, OFMT variable and: User-modified. (line 113)
* print statement, See Also redirection, of output: Redirection.
(line 17)
* print statement, sprintf() function and: Round Function. (line 6)
@@ -33278,27 +33566,27 @@ Index
* printing, unduplicated lines of text: Uniq Program. (line 6)
* printing, user information: Id Program. (line 6)
* private variables: Library Names. (line 11)
-* process group idIDof gawk process: Auto-set. (line 183)
-* process ID of gawk process: Auto-set. (line 186)
+* process group idIDof gawk process: Auto-set. (line 190)
+* process ID of gawk process: Auto-set. (line 193)
* processes, two-way communications with: Two-way I/O. (line 6)
* processing data: Basic High Level. (line 6)
* PROCINFO array <1>: Passwd Functions. (line 6)
* PROCINFO array <2>: Time Functions. (line 47)
-* PROCINFO array: Auto-set. (line 136)
+* PROCINFO array: Auto-set. (line 137)
* PROCINFO array, and communications via ptys: Two-way I/O. (line 99)
* PROCINFO array, and group membership: Group Functions. (line 6)
* PROCINFO array, and user and group ID numbers: Id Program. (line 15)
* PROCINFO array, testing the field splitting: Passwd Functions.
- (line 161)
-* PROCINFO array, uses: Auto-set. (line 242)
+ (line 154)
+* PROCINFO array, uses: Auto-set. (line 249)
* PROCINFO, values of sorted_in: Controlling Scanning.
(line 26)
* profiling awk programs: Profiling. (line 6)
* profiling awk programs, dynamically: Profiling. (line 179)
-* program identifiers: Auto-set. (line 154)
+* program identifiers: Auto-set. (line 155)
* program, definition of: Getting Started. (line 21)
* programming conventions, --non-decimal-data option: Nondecimal Data.
- (line 36)
+ (line 35)
* programming conventions, ARGC/ARGV variables: Auto-set. (line 35)
* programming conventions, exit statement: Exit Statement. (line 38)
* programming conventions, function parameters: Return Statement.
@@ -33306,7 +33594,7 @@ Index
* programming conventions, functions, calling: Calling Built-in.
(line 10)
* programming conventions, functions, writing: Definition Syntax.
- (line 61)
+ (line 65)
* programming conventions, gawk extensions: Internal File Ops.
(line 45)
* programming conventions, private variable names: Library Names.
@@ -33326,13 +33614,13 @@ Index
* question mark (?), ?: operator: Precedence. (line 92)
* question mark (?), regexp operator <1>: GNU Regexp Operators.
(line 59)
-* question mark (?), regexp operator: Regexp Operators. (line 112)
+* question mark (?), regexp operator: Regexp Operators. (line 111)
* QuikTrim Awk: Other Versions. (line 135)
* quit debugger command: Miscellaneous Debugger Commands.
(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)
@@ -33348,12 +33636,11 @@ Index
* range expressions (regexps): Bracket Expressions. (line 6)
* range patterns: Ranges. (line 6)
* range patterns, line continuation and: Ranges. (line 65)
-* Rankin, Pat <1>: Bugs. (line 71)
-* Rankin, Pat <2>: Contributors. (line 37)
-* Rankin, Pat <3>: Assignment Ops. (line 100)
+* Rankin, Pat <1>: Contributors. (line 37)
+* Rankin, Pat <2>: Assignment Ops. (line 100)
* Rankin, Pat: Acknowledgments. (line 60)
* reada() extension function: Extension Sample Read write array.
- (line 15)
+ (line 18)
* readable data files, checking: File Checking. (line 6)
* readable.awk program: File Checking. (line 11)
* readdir extension: Extension Sample Readdir.
@@ -33363,20 +33650,20 @@ Index
* readfile() user-defined function: Readfile Function. (line 30)
* reading input files: Reading Files. (line 6)
* recipe for a programming language: History. (line 6)
-* record separators <1>: User-modified. (line 133)
+* record separators <1>: User-modified. (line 132)
* 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)
-* recursive functions: Definition Syntax. (line 79)
+* 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)
* redirection of output: Redirection. (line 6)
@@ -33384,7 +33671,7 @@ Index
(line 77)
* regexp: Regexp. (line 6)
* regexp constants <1>: Comparison Operators.
- (line 102)
+ (line 103)
* regexp constants <2>: Regexp Constants. (line 6)
* regexp constants: Regexp Usage. (line 57)
* regexp constants, /=.../, /= operator and: Assignment Ops. (line 148)
@@ -33403,7 +33690,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)
@@ -33414,7 +33701,7 @@ Index
(line 59)
* regular expressions, gawk, command-line options: GNU Regexp Operators.
(line 70)
-* regular expressions, interval expressions and: Options. (line 277)
+* regular expressions, interval expressions and: Options. (line 279)
* regular expressions, leftmost longest match: Leftmost Longest.
(line 6)
* regular expressions, operators <1>: Regexp Operators. (line 6)
@@ -33426,16 +33713,16 @@ Index
* regular expressions, operators, gawk: GNU Regexp Operators.
(line 6)
* regular expressions, operators, precedence of: Regexp Operators.
- (line 157)
+ (line 156)
* regular expressions, searching for: Egrep Program. (line 6)
* relational operators, See comparison operators: Typing and Comparison.
(line 9)
-* replace in string: String Functions. (line 406)
+* replace in string: String Functions. (line 407)
* return debugger command: Debugger Execution Control.
(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)
@@ -33451,40 +33738,40 @@ Index
(line 11)
* right angle bracket (>), >> operator (I/O) <1>: Precedence. (line 65)
* right angle bracket (>), >> operator (I/O): Redirection. (line 50)
-* right shift: Bitwise Functions. (line 52)
+* right shift: Bitwise Functions. (line 53)
* right shift, bitwise: Bitwise Functions. (line 32)
* Ritchie, Dennis: Basic Data Typing. (line 54)
-* RLENGTH variable: Auto-set. (line 252)
-* RLENGTH variable, match() function and: String Functions. (line 224)
+* RLENGTH variable: Auto-set. (line 259)
+* RLENGTH variable, match() function and: String Functions. (line 227)
* Robbins, Arnold <1>: Future Extensions. (line 6)
-* Robbins, Arnold <2>: Bugs. (line 32)
-* Robbins, Arnold <3>: Contributors. (line 141)
+* Robbins, Arnold <2>: Bugs. (line 72)
+* Robbins, Arnold <3>: Contributors. (line 144)
* Robbins, Arnold <4>: General Data Types. (line 6)
* Robbins, Arnold <5>: Alarm Program. (line 6)
* 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)
+* Robbins, Harry: Acknowledgments. (line 94)
+* Robbins, Jean: Acknowledgments. (line 94)
* Robbins, Miriam <1>: Passwd Functions. (line 90)
* Robbins, Miriam <2>: Getline/Pipe. (line 39)
-* Robbins, Miriam: Acknowledgments. (line 92)
+* Robbins, Miriam: Acknowledgments. (line 94)
* Rommel, Kai Uwe: Contributors. (line 42)
* round to nearest integer: Numeric Functions. (line 38)
* round() user-defined function: Round Function. (line 16)
* rounding numbers: Round Function. (line 6)
-* ROUNDMODE variable: User-modified. (line 128)
-* RS variable <1>: User-modified. (line 133)
+* ROUNDMODE variable: User-modified. (line 127)
+* RS variable <1>: User-modified. (line 132)
* RS variable: awk split records. (line 12)
* RS variable, multiline records and: Multiple Line. (line 17)
-* rshift: Bitwise Functions. (line 52)
-* RSTART variable: Auto-set. (line 258)
-* RSTART variable, match() function and: String Functions. (line 224)
-* RT variable <1>: Auto-set. (line 265)
+* rshift: Bitwise Functions. (line 53)
+* RSTART variable: Auto-set. (line 265)
+* RSTART variable, match() function and: String Functions. (line 227)
+* RT variable <1>: Auto-set. (line 272)
* 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)
@@ -33495,14 +33782,14 @@ Index
(line 68)
* sample debugging session: Sample Debugging Session.
(line 6)
-* sandbox mode: Options. (line 284)
+* sandbox mode: Options. (line 286)
* save debugger options: Debugger Info. (line 84)
* scalar or array: Type Functions. (line 11)
* scalar values: Basic Data Typing. (line 13)
* scanning arrays: Scanning an Array. (line 6)
* scanning multidimensional arrays: Multiscanning. (line 11)
* Schorr, Andrew <1>: Contributors. (line 133)
-* Schorr, Andrew <2>: Auto-set. (line 292)
+* Schorr, Andrew <2>: Auto-set. (line 304)
* Schorr, Andrew: Acknowledgments. (line 60)
* Schreiber, Bert: Acknowledgments. (line 38)
* Schreiber, Rita: Acknowledgments. (line 38)
@@ -33510,11 +33797,11 @@ Index
* search in string: String Functions. (line 155)
* search paths <1>: VMS Running. (line 58)
* search paths <2>: PC Using. (line 10)
-* search paths: Programs Exercises. (line 63)
+* search paths: Programs Exercises. (line 70)
* search paths, for loadable extensions: AWKLIBPATH Variable. (line 6)
* search paths, for source files <1>: VMS Running. (line 58)
* search paths, for source files <2>: PC Using. (line 10)
-* search paths, for source files <3>: Programs Exercises. (line 63)
+* search paths, for source files <3>: Programs Exercises. (line 70)
* search paths, for source files: AWKPATH Variable. (line 6)
* searching, files for regular expressions: Egrep Program. (line 6)
* searching, for words: Dupword Program. (line 6)
@@ -33534,22 +33821,21 @@ Index
* separators, field, FIELDWIDTHS variable and: User-modified. (line 37)
* separators, field, FPAT variable and: User-modified. (line 43)
* separators, field, POSIX and: Fields. (line 6)
-* separators, for records <1>: User-modified. (line 133)
+* separators, for records <1>: User-modified. (line 132)
* 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)
+* separators, subscript: User-modified. (line 145)
* set breakpoint: Breakpoint Control. (line 11)
* set debugger command: Viewing And Changing Data.
(line 59)
* set directory of message catalogs: I18N Functions. (line 12)
* set watchpoint: Viewing And Changing Data.
(line 67)
-* shadowing of variable values: Definition Syntax. (line 67)
-* shell quoting, double quote: Read Terminal. (line 25)
+* 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)
@@ -33558,7 +33844,7 @@ Index
* shells, variables: Using Shell Variables.
(line 6)
* shift, bitwise: Bitwise Functions. (line 32)
-* short-circuit operators: Boolean Ops. (line 57)
+* short-circuit operators: Boolean Ops. (line 59)
* show all source files, in debugger: Debugger Info. (line 45)
* show breakpoints: Debugger Info. (line 21)
* show function arguments, in debugger: Debugger Info. (line 18)
@@ -33584,35 +33870,35 @@ Index
* sidebar, A Constant's Base Does Not Affect Its Value: Nondecimal-numbers.
(line 64)
* sidebar, Backslash Before Regular Characters: Escape Sequences.
- (line 116)
+ (line 118)
* sidebar, Changing FS Does Not Affect the Fields: Field Splitting Summary.
(line 38)
-* sidebar, Changing NR and FNR: Auto-set. (line 307)
+* sidebar, Changing NR and FNR: Auto-set. (line 319)
* sidebar, Controlling Output Buffering with system(): I/O Functions.
- (line 138)
+ (line 137)
* sidebar, Escape Sequences for Metacharacters: Escape Sequences.
- (line 134)
+ (line 136)
* sidebar, FS and IGNORECASE: Field Splitting Summary.
(line 64)
* sidebar, Interactive Versus Noninteractive Buffering: I/O Functions.
- (line 107)
-* sidebar, Matching the Null String: Gory Details. (line 141)
+ (line 106)
+* sidebar, Matching the Null String: String Functions. (line 533)
* sidebar, Operator Evaluation Order: Increment Ops. (line 58)
-* sidebar, Piping into sh: Redirection. (line 140)
-* sidebar, Portability Issues with #!: Executable Scripts. (line 31)
+* 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)
* sidebar, RS = "\0" Is Not Portable: gawk split records. (line 63)
* sidebar, So Why Does gawk have BEGINFILE and ENDFILE?: Filetrans Function.
- (line 83)
+ (line 82)
* sidebar, Syntactic Ambiguities Between /= and Regular Expressions: Assignment Ops.
(line 146)
+* sidebar, Understanding #!: Executable Scripts. (line 31)
* sidebar, Understanding $0: Changing Fields. (line 134)
* 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)
@@ -33627,21 +33913,21 @@ Index
* sin: Numeric Functions. (line 91)
* sine: Numeric Functions. (line 91)
* 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.
(line 43)
* Skywalker, Luke: Undocumented. (line 6)
-* sleep utility: Alarm Program. (line 111)
+* sleep utility: Alarm Program. (line 110)
* sleep() extension function: Extension Sample Time.
(line 22)
* Solaris, POSIX-compliant awk: Other Versions. (line 96)
-* sort array: String Functions. (line 42)
-* sort array indices: String Functions. (line 42)
+* sort array: String Functions. (line 41)
+* sort array indices: String Functions. (line 41)
* sort function, arrays, sorting: Array Sorting Functions.
(line 6)
* sort utility: Word Sorting. (line 50)
@@ -33662,17 +33948,17 @@ Index
* source code, QSE Awk: Other Versions. (line 131)
* source code, QuikTrim Awk: Other Versions. (line 135)
* source code, Solaris awk: Other Versions. (line 96)
-* source files, search path for: Programs Exercises. (line 63)
-* sparse arrays: Array Intro. (line 71)
+* source files, search path for: Programs Exercises. (line 70)
+* sparse arrays: Array Intro. (line 72)
* Spencer, Henry: Glossary. (line 11)
-* split: String Functions. (line 313)
-* split string into array: String Functions. (line 294)
+* split: String Functions. (line 315)
+* split string into array: String Functions. (line 296)
* split utility: Split Program. (line 6)
* split() function, array elements, deleting: Delete. (line 61)
* split.awk program: Split Program. (line 30)
-* sprintf <1>: String Functions. (line 381)
+* sprintf <1>: String Functions. (line 382)
* sprintf: OFMT. (line 15)
-* sprintf() function, OFMT variable and: User-modified. (line 114)
+* sprintf() function, OFMT variable and: User-modified. (line 113)
* sprintf() function, print/printf statements and: Round Function.
(line 6)
* sqrt: Numeric Functions. (line 94)
@@ -33708,18 +33994,18 @@ Index
* string constants, vs. regexp constants: Computed Regexps. (line 39)
* string extraction (internationalization): String Extraction.
(line 6)
-* string length: String Functions. (line 167)
+* string length: String Functions. (line 170)
* string operators: Concatenation. (line 8)
-* string, regular expression match: String Functions. (line 207)
+* string, regular expression match: String Functions. (line 210)
* string-manipulation functions: String Functions. (line 6)
* string-matching operators: Regexp Usage. (line 19)
* string-translation functions: I18N Functions. (line 6)
-* strings splitting, example: String Functions. (line 333)
-* strings, converting <1>: Bitwise Functions. (line 109)
+* strings splitting, example: String Functions. (line 334)
+* strings, converting <1>: Bitwise Functions. (line 110)
* strings, converting: Strings And Numbers. (line 6)
-* strings, converting letter case: String Functions. (line 520)
+* strings, converting letter case: String Functions. (line 521)
* 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)
@@ -33727,15 +34013,15 @@ Index
* strings, null: Regexp Field Splitting.
(line 43)
* strings, numeric: Variable Typing. (line 6)
-* strtonum: String Functions. (line 388)
+* strtonum: String Functions. (line 389)
* strtonum() function (gawk), --non-decimal-data option and: Nondecimal Data.
- (line 36)
-* sub <1>: String Functions. (line 406)
+ (line 35)
+* sub <1>: String Functions. (line 407)
* sub: Using Constant Regexps.
(line 43)
-* sub() function, arguments of: String Functions. (line 460)
+* sub() function, arguments of: String Functions. (line 461)
* sub() function, escape processing: Gory Details. (line 6)
-* subscript separators: User-modified. (line 146)
+* subscript separators: User-modified. (line 145)
* subscripts in arrays, multidimensional: Multidimensional. (line 10)
* subscripts in arrays, multidimensional, scanning: Multiscanning.
(line 11)
@@ -33743,30 +34029,30 @@ Index
(line 6)
* subscripts in arrays, uninitialized variables as: Uninitialized Subscripts.
(line 6)
-* SUBSEP variable: User-modified. (line 146)
+* SUBSEP variable: User-modified. (line 145)
* SUBSEP variable, and multidimensional arrays: Multidimensional.
(line 16)
* substitute in string: String Functions. (line 89)
-* substr: String Functions. (line 479)
-* substring: String Functions. (line 479)
+* substr: String Functions. (line 480)
+* substring: String Functions. (line 480)
* Sumner, Andrew: Other Versions. (line 64)
-* supplementary groups of gawk process: Auto-set. (line 237)
+* supplementary groups of gawk process: Auto-set. (line 244)
* switch statement: Switch Statement. (line 6)
-* SYMTAB array: Auto-set. (line 269)
+* SYMTAB array: Auto-set. (line 276)
* syntactic ambiguity: /= operator vs. /=.../ regexp constant: Assignment Ops.
(line 148)
-* system: I/O Functions. (line 75)
+* system: I/O Functions. (line 74)
* systime: Time Functions. (line 66)
* t debugger command (alias for tbreak): Breakpoint Control. (line 90)
* tbreak debugger command: Breakpoint Control. (line 90)
-* Tcl: Library Names. (line 57)
+* Tcl: Library Names. (line 58)
* TCP/IP: TCP/IP Networking. (line 6)
* TCP/IP, support for: Special Network. (line 6)
* 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)
-* testbits.awk program: Bitwise Functions. (line 70)
+* terminating records: awk split records. (line 125)
+* testbits.awk program: Bitwise Functions. (line 71)
* testext extension: Extension Sample API Tests.
(line 6)
* Texinfo <1>: Adding Code. (line 100)
@@ -33782,7 +34068,7 @@ Index
* text, printing: Print. (line 22)
* text, printing, unduplicated lines of: Uniq Program. (line 6)
* TEXTDOMAIN variable <1>: Programmer i18n. (line 9)
-* TEXTDOMAIN variable: User-modified. (line 152)
+* TEXTDOMAIN variable: User-modified. (line 151)
* TEXTDOMAIN variable, BEGIN pattern and: Programmer i18n. (line 60)
* TEXTDOMAIN variable, portability and: I18N Portability. (line 20)
* textdomain() function (C library): Explaining gettext. (line 28)
@@ -33791,8 +34077,8 @@ Index
* tilde (~), ~ operator <3>: Comparison Operators.
(line 11)
* tilde (~), ~ operator <4>: Regexp Constants. (line 6)
-* tilde (~), ~ operator <5>: Computed Regexps. (line 6)
-* tilde (~), ~ operator <6>: Case-sensitivity. (line 26)
+* tilde (~), ~ operator <5>: Case-sensitivity. (line 26)
+* tilde (~), ~ operator <6>: Computed Regexps. (line 6)
* tilde (~), ~ operator: Regexp Usage. (line 19)
* time functions: Time Functions. (line 6)
* time, alarm clock example program: Alarm Program. (line 11)
@@ -33805,45 +34091,45 @@ Index
* timestamps, converting dates to: Time Functions. (line 76)
* timestamps, formatted: Getlocaltime Function.
(line 6)
-* tolower: String Functions. (line 521)
-* toupper: String Functions. (line 527)
+* tolower: String Functions. (line 522)
+* toupper: String Functions. (line 528)
* tr utility: Translate Program. (line 6)
* trace debugger command: Miscellaneous Debugger Commands.
(line 108)
* 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)
* troubleshooting, awk uses FS not IFS: Field Separators. (line 30)
* troubleshooting, backslash before nonspecial character: Escape Sequences.
- (line 118)
+ (line 120)
* troubleshooting, division: Arithmetic Ops. (line 44)
* troubleshooting, fatal errors, field widths, specifying: Constant Size.
(line 23)
* troubleshooting, fatal errors, printf format strings: Format Modifiers.
- (line 159)
-* troubleshooting, fflush() function: I/O Functions. (line 63)
+ (line 158)
+* troubleshooting, fflush() function: I/O Functions. (line 62)
* troubleshooting, function call syntax: Function Calls. (line 30)
* troubleshooting, gawk: Compatibility Mode. (line 6)
* troubleshooting, gawk, bug reports: Bugs. (line 9)
* troubleshooting, gawk, fatal errors, function arguments: Calling Built-in.
(line 16)
* troubleshooting, getline function: File Checking. (line 25)
-* troubleshooting, gsub()/sub() functions: String Functions. (line 470)
-* troubleshooting, match() function: String Functions. (line 289)
+* troubleshooting, gsub()/sub() functions: String Functions. (line 471)
+* troubleshooting, match() function: String Functions. (line 291)
* 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 62)
* troubleshooting, readable data files: File Checking. (line 6)
* troubleshooting, regexp constants vs. string constants: Computed Regexps.
(line 39)
* troubleshooting, string concatenation: Concatenation. (line 26)
-* troubleshooting, substr() function: String Functions. (line 497)
-* troubleshooting, system() function: I/O Functions. (line 97)
+* troubleshooting, substr() function: String Functions. (line 498)
+* troubleshooting, system() function: I/O Functions. (line 96)
* troubleshooting, typographical errors, global variables: Options.
(line 98)
* true, logical: Truth Values. (line 6)
@@ -33875,11 +34161,11 @@ Index
* uniq.awk program: Uniq Program. (line 65)
* Unix: Glossary. (line 611)
* Unix awk, backslashes in escape sequences: Escape Sequences.
- (line 130)
+ (line 132)
* 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)
@@ -33887,7 +34173,7 @@ Index
(line 83)
* unwatch debugger command: Viewing And Changing Data.
(line 84)
-* up debugger command: Execution Stack. (line 34)
+* up debugger command: Execution Stack. (line 36)
* user database, reading: Passwd Functions. (line 6)
* user-defined functions: User-defined. (line 6)
* user-defined, functions, counts, in a profile: Profiling. (line 137)
@@ -33898,17 +34184,14 @@ 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 19)
+* variable assignments and input files: Other Arguments. (line 26)
* variable typing: Typing and Comparison.
(line 9)
* variables <1>: Basic Data Typing. (line 6)
* variables: Other Features. (line 6)
* variables, assigning on command line: Assignment Options. (line 6)
-* variables, built-in <1>: Built-in Variables. (line 6)
-* variables, built-in: Using Variables. (line 20)
-* variables, built-in, -v option, setting with: Options. (line 40)
-* variables, built-in, conveying information: Auto-set. (line 6)
-* variables, flag: Boolean Ops. (line 67)
+* variables, built-in: Using Variables. (line 23)
+* variables, flag: Boolean Ops. (line 69)
* variables, getline command into, using <1>: Getline/Variable/Coprocess.
(line 6)
* variables, getline command into, using <2>: Getline/Variable/Pipe.
@@ -33918,22 +34201,24 @@ Index
* variables, getline command into, using: Getline/Variable. (line 6)
* variables, global, for library functions: Library Names. (line 11)
* variables, global, printing list of: Options. (line 93)
-* variables, initializing: Using Variables. (line 20)
+* variables, initializing: Using Variables. (line 23)
* variables, local to a function: Variable Scope. (line 6)
-* variables, names of: Arrays. (line 18)
+* variables, predefined: Built-in Variables. (line 6)
+* variables, predefined -v option, setting with: Options. (line 40)
+* variables, predefined conveying information: Auto-set. (line 6)
* variables, private: Library Names. (line 11)
* variables, setting: Options. (line 32)
-* variables, shadowing: Definition Syntax. (line 67)
+* variables, shadowing: Definition Syntax. (line 71)
* variables, types of: Assignment Ops. (line 40)
* variables, types of, comparison expressions and: Typing and Comparison.
(line 9)
* variables, uninitialized, as array subscripts: Uninitialized Subscripts.
(line 6)
* variables, user-defined: Variables. (line 6)
-* version of gawk: Auto-set. (line 207)
-* version of gawk extension API: Auto-set. (line 232)
-* version of GNU MP library: Auto-set. (line 218)
-* version of GNU MPFR library: Auto-set. (line 214)
+* version of gawk: Auto-set. (line 214)
+* version of gawk extension API: Auto-set. (line 239)
+* version of GNU MP library: Auto-set. (line 225)
+* version of GNU MPFR library: Auto-set. (line 221)
* vertical bar (|): Regexp Operators. (line 70)
* vertical bar (|), | operator (I/O) <1>: Precedence. (line 65)
* vertical bar (|), | operator (I/O): Getline/Pipe. (line 9)
@@ -33941,7 +34226,7 @@ Index
* vertical bar (|), |& operator (I/O) <2>: Precedence. (line 65)
* vertical bar (|), |& operator (I/O): Getline/Coprocess. (line 6)
* vertical bar (|), || operator <1>: Precedence. (line 89)
-* vertical bar (|), || operator: Boolean Ops. (line 57)
+* vertical bar (|), || operator: Boolean Ops. (line 59)
* Vinschen, Corinna: Acknowledgments. (line 60)
* w debugger command (alias for watch): Viewing And Changing Data.
(line 67)
@@ -33962,12 +34247,15 @@ Index
* wc.awk program: Wc Program. (line 46)
* Weinberger, Peter <1>: Contributors. (line 11)
* Weinberger, Peter: History. (line 17)
+* where debugger command: Execution Stack. (line 13)
+* where debugger command (alias for backtrace): Execution Stack.
+ (line 13)
* while statement: While Statement. (line 6)
* while statement, use of regexps in: Regexp Usage. (line 19)
* whitespace, as field separators: Default Field Splitting.
(line 6)
* whitespace, functions, calling: Calling Built-in. (line 10)
-* whitespace, newlines as: Options. (line 258)
+* whitespace, newlines as: Options. (line 260)
* Williams, Kent: Contributors. (line 34)
* Woehlke, Matthew: Contributors. (line 79)
* Woods, John: Contributors. (line 27)
@@ -33982,12 +34270,12 @@ Index
* words, duplicate, searching for: Dupword Program. (line 6)
* words, usage counts, generating: Word Sorting. (line 6)
* writea() extension function: Extension Sample Read write array.
- (line 9)
+ (line 12)
* xgettext utility: String Extraction. (line 13)
-* xor: Bitwise Functions. (line 55)
+* xor: Bitwise Functions. (line 56)
* XOR bitwise operation: Bitwise Functions. (line 6)
* Yawitz, Efraim: Contributors. (line 131)
-* Zaretskii, Eli <1>: Bugs. (line 71)
+* Zaretskii, Eli <1>: Bugs. (line 72)
* Zaretskii, Eli <2>: Contributors. (line 55)
* Zaretskii, Eli: Acknowledgments. (line 60)
* zerofile.awk program: Empty Files. (line 21)
@@ -34001,571 +34289,576 @@ 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)
+* | (vertical bar), || operator: Boolean Ops. (line 59)
* ~ (tilde), ~ operator <1>: Expression Patterns. (line 24)
* ~ (tilde), ~ operator <2>: Precedence. (line 80)
* ~ (tilde), ~ operator <3>: Comparison Operators.
(line 11)
* ~ (tilde), ~ operator <4>: Regexp Constants. (line 6)
-* ~ (tilde), ~ operator <5>: Computed Regexps. (line 6)
-* ~ (tilde), ~ operator <6>: Case-sensitivity. (line 26)
+* ~ (tilde), ~ operator <5>: Case-sensitivity. (line 26)
+* ~ (tilde), ~ operator <6>: Computed Regexps. (line 6)
* ~ (tilde), ~ operator: Regexp Usage. (line 19)

Tag Table:
Node: Top1204
-Node: Foreword41858
-Node: Preface46203
-Ref: Preface-Footnote-149226
-Ref: Preface-Footnote-249333
-Node: History49565
-Node: Names51939
-Ref: Names-Footnote-153403
-Node: This Manual53476
-Ref: This Manual-Footnote-159255
-Node: Conventions59355
-Node: Manual History61700
-Ref: Manual History-Footnote-164776
-Ref: Manual History-Footnote-264817
-Node: How To Contribute64891
-Node: Acknowledgments66130
-Node: Getting Started70878
-Node: Running gawk73312
-Node: One-shot74502
-Node: Read Terminal75727
-Ref: Read Terminal-Footnote-177690
-Node: Long77861
-Node: Executable Scripts79255
-Ref: Executable Scripts-Footnote-181088
-Ref: Executable Scripts-Footnote-281190
-Node: Comments81743
-Node: Quoting84216
-Node: DOS Quoting89529
-Node: Sample Data Files90204
-Node: Very Simple92758
-Node: Two Rules97531
-Node: More Complex99425
-Ref: More Complex-Footnote-1102357
-Node: Statements/Lines102442
-Ref: Statements/Lines-Footnote-1106898
-Node: Other Features107163
-Node: When108091
-Ref: When-Footnote-1109952
-Node: Intro Summary110017
-Node: Invoking Gawk110783
-Node: Command Line112298
-Node: Options113089
-Ref: Options-Footnote-1128736
-Node: Other Arguments128761
-Node: Naming Standard Input131423
-Node: Environment Variables132516
-Node: AWKPATH Variable133074
-Ref: AWKPATH Variable-Footnote-1135940
-Ref: AWKPATH Variable-Footnote-2135985
-Node: AWKLIBPATH Variable136245
-Node: Other Environment Variables137004
-Node: Exit Status140456
-Node: Include Files141131
-Node: Loading Shared Libraries144709
-Node: Obsolete146093
-Node: Undocumented146790
-Node: Invoking Summary147057
-Node: Regexp148657
-Node: Regexp Usage150107
-Node: Escape Sequences152140
-Node: Regexp Operators158040
-Ref: Regexp Operators-Footnote-1165520
-Ref: Regexp Operators-Footnote-2165667
-Node: Bracket Expressions165765
-Ref: table-char-classes167655
-Node: GNU Regexp Operators170595
-Node: Case-sensitivity174304
-Ref: Case-sensitivity-Footnote-1177196
-Ref: Case-sensitivity-Footnote-2177431
-Node: Leftmost Longest177539
-Node: Computed Regexps178740
-Node: Regexp Summary182112
-Node: Reading Files183581
-Node: Records185673
-Node: awk split records186416
-Node: gawk split records191274
-Ref: gawk split records-Footnote-1195795
-Node: Fields195832
-Ref: Fields-Footnote-1198796
-Node: Nonconstant Fields198882
-Ref: Nonconstant Fields-Footnote-1201112
-Node: Changing Fields201314
-Node: Field Separators207268
-Node: Default Field Splitting209970
-Node: Regexp Field Splitting211087
-Node: Single Character Fields214414
-Node: Command Line Field Separator215473
-Node: Full Line Fields218899
-Ref: Full Line Fields-Footnote-1219407
-Node: Field Splitting Summary219453
-Ref: Field Splitting Summary-Footnote-1222585
-Node: Constant Size222686
-Node: Splitting By Content227292
-Ref: Splitting By Content-Footnote-1231365
-Node: Multiple Line231405
-Ref: Multiple Line-Footnote-1237261
-Node: Getline237440
-Node: Plain Getline239656
-Node: Getline/Variable241751
-Node: Getline/File242898
-Node: Getline/Variable/File244282
-Ref: Getline/Variable/File-Footnote-1245881
-Node: Getline/Pipe245968
-Node: Getline/Variable/Pipe248654
-Node: Getline/Coprocess249761
-Node: Getline/Variable/Coprocess251013
-Node: Getline Notes251750
-Node: Getline Summary254554
-Ref: table-getline-variants254962
-Node: Read Timeout255874
-Ref: Read Timeout-Footnote-1259701
-Node: Command-line directories259759
-Node: Input Summary260663
-Node: Input Exercises263800
-Node: Printing264533
-Node: Print266255
-Node: Print Examples267748
-Node: Output Separators270527
-Node: OFMT272543
-Node: Printf273901
-Node: Basic Printf274807
-Node: Control Letters276346
-Node: Format Modifiers280337
-Node: Printf Examples286364
-Node: Redirection288828
-Node: Special Files295800
-Node: Special FD296333
-Ref: Special FD-Footnote-1299930
-Node: Special Network300004
-Node: Special Caveats300854
-Node: Close Files And Pipes301650
-Ref: Close Files And Pipes-Footnote-1308811
-Ref: Close Files And Pipes-Footnote-2308959
-Node: Output Summary309109
-Node: Output exercises310106
-Node: Expressions310786
-Node: Values311971
-Node: Constants312647
-Node: Scalar Constants313327
-Ref: Scalar Constants-Footnote-1314186
-Node: Nondecimal-numbers314436
-Node: Regexp Constants317436
-Node: Using Constant Regexps317911
-Node: Variables320983
-Node: Using Variables321638
-Node: Assignment Options323362
-Node: Conversion325237
-Node: Strings And Numbers325761
-Ref: Strings And Numbers-Footnote-1328823
-Node: Locale influences conversions328932
-Ref: table-locale-affects331649
-Node: All Operators332237
-Node: Arithmetic Ops332867
-Node: Concatenation335372
-Ref: Concatenation-Footnote-1338191
-Node: Assignment Ops338297
-Ref: table-assign-ops343280
-Node: Increment Ops344583
-Node: Truth Values and Conditions348021
-Node: Truth Values349104
-Node: Typing and Comparison350153
-Node: Variable Typing350946
-Node: Comparison Operators354598
-Ref: table-relational-ops355008
-Node: POSIX String Comparison358558
-Ref: POSIX String Comparison-Footnote-1359642
-Node: Boolean Ops359780
-Ref: Boolean Ops-Footnote-1363850
-Node: Conditional Exp363941
-Node: Function Calls365668
-Node: Precedence369548
-Node: Locales373217
-Node: Expressions Summary374848
-Node: Patterns and Actions377389
-Node: Pattern Overview378505
-Node: Regexp Patterns380182
-Node: Expression Patterns380725
-Node: Ranges384506
-Node: BEGIN/END387612
-Node: Using BEGIN/END388374
-Ref: Using BEGIN/END-Footnote-1391110
-Node: I/O And BEGIN/END391216
-Node: BEGINFILE/ENDFILE393487
-Node: Empty396418
-Node: Using Shell Variables396735
-Node: Action Overview399018
-Node: Statements401345
-Node: If Statement403193
-Node: While Statement404691
-Node: Do Statement406735
-Node: For Statement407891
-Node: Switch Statement411043
-Node: Break Statement413431
-Node: Continue Statement415472
-Node: Next Statement417297
-Node: Nextfile Statement419687
-Node: Exit Statement422323
-Node: Built-in Variables424727
-Node: User-modified425854
-Ref: User-modified-Footnote-1433543
-Node: Auto-set433605
-Ref: Auto-set-Footnote-1446524
-Ref: Auto-set-Footnote-2446729
-Node: ARGC and ARGV446785
-Node: Pattern Action Summary450689
-Node: Arrays452912
-Node: Array Basics454461
-Node: Array Intro455287
-Ref: figure-array-elements457260
-Node: Reference to Elements459667
-Node: Assigning Elements462046
-Node: Array Example462537
-Node: Scanning an Array464269
-Node: Controlling Scanning467270
-Ref: Controlling Scanning-Footnote-1472443
-Node: Delete472759
-Ref: Delete-Footnote-1475510
-Node: Numeric Array Subscripts475567
-Node: Uninitialized Subscripts477750
-Node: Multidimensional479375
-Node: Multiscanning482488
-Node: Arrays of Arrays484077
-Node: Arrays Summary488740
-Node: Functions490845
-Node: Built-in491718
-Node: Calling Built-in492796
-Node: Numeric Functions494784
-Ref: Numeric Functions-Footnote-1499620
-Ref: Numeric Functions-Footnote-2499977
-Ref: Numeric Functions-Footnote-3500025
-Node: String Functions500294
-Ref: String Functions-Footnote-1523291
-Ref: String Functions-Footnote-2523420
-Ref: String Functions-Footnote-3523668
-Node: Gory Details523755
-Ref: table-sub-escapes525528
-Ref: table-sub-proposed527048
-Ref: table-posix-sub528412
-Ref: table-gensub-escapes529952
-Ref: Gory Details-Footnote-1531128
-Node: I/O Functions531279
-Ref: I/O Functions-Footnote-1538389
-Node: Time Functions538536
-Ref: Time Functions-Footnote-1549000
-Ref: Time Functions-Footnote-2549068
-Ref: Time Functions-Footnote-3549226
-Ref: Time Functions-Footnote-4549337
-Ref: Time Functions-Footnote-5549449
-Ref: Time Functions-Footnote-6549676
-Node: Bitwise Functions549942
-Ref: table-bitwise-ops550504
-Ref: Bitwise Functions-Footnote-1554749
-Node: Type Functions554933
-Node: I18N Functions556075
-Node: User-defined557720
-Node: Definition Syntax558524
-Ref: Definition Syntax-Footnote-1563703
-Node: Function Example563772
-Ref: Function Example-Footnote-1566412
-Node: Function Caveats566434
-Node: Calling A Function566952
-Node: Variable Scope567907
-Node: Pass By Value/Reference570895
-Node: Return Statement574405
-Node: Dynamic Typing577389
-Node: Indirect Calls578318
-Node: Functions Summary588031
-Node: Library Functions590570
-Ref: Library Functions-Footnote-1594188
-Ref: Library Functions-Footnote-2594331
-Node: Library Names594502
-Ref: Library Names-Footnote-1597975
-Ref: Library Names-Footnote-2598195
-Node: General Functions598281
-Node: Strtonum Function599309
-Node: Assert Function602089
-Node: Round Function605415
-Node: Cliff Random Function606956
-Node: Ordinal Functions607972
-Ref: Ordinal Functions-Footnote-1611049
-Ref: Ordinal Functions-Footnote-2611301
-Node: Join Function611512
-Ref: Join Function-Footnote-1613283
-Node: Getlocaltime Function613483
-Node: Readfile Function617219
-Node: Data File Management619058
-Node: Filetrans Function619690
-Node: Rewind Function623759
-Node: File Checking625317
-Ref: File Checking-Footnote-1626449
-Node: Empty Files626650
-Node: Ignoring Assigns628629
-Node: Getopt Function630183
-Ref: Getopt Function-Footnote-1641486
-Node: Passwd Functions641689
-Ref: Passwd Functions-Footnote-1650668
-Node: Group Functions650756
-Ref: Group Functions-Footnote-1658697
-Node: Walking Arrays658910
-Node: Library Functions Summary660513
-Node: Library exercises661901
-Node: Sample Programs663181
-Node: Running Examples663951
-Node: Clones664679
-Node: Cut Program665903
-Node: Egrep Program675771
-Ref: Egrep Program-Footnote-1683742
-Node: Id Program683852
-Node: Split Program687516
-Ref: Split Program-Footnote-1691054
-Node: Tee Program691182
-Node: Uniq Program693989
-Node: Wc Program701419
-Ref: Wc Program-Footnote-1705684
-Node: Miscellaneous Programs705776
-Node: Dupword Program706989
-Node: Alarm Program709020
-Node: Translate Program713834
-Ref: Translate Program-Footnote-1718225
-Ref: Translate Program-Footnote-2718495
-Node: Labels Program718629
-Ref: Labels Program-Footnote-1722000
-Node: Word Sorting722084
-Node: History Sorting726127
-Node: Extract Program727963
-Node: Simple Sed735499
-Node: Igawk Program738561
-Ref: Igawk Program-Footnote-1752865
-Ref: Igawk Program-Footnote-2753066
-Node: Anagram Program753204
-Node: Signature Program756272
-Node: Programs Summary757519
-Node: Programs Exercises758734
-Node: Advanced Features762385
-Node: Nondecimal Data764333
-Node: Array Sorting765910
-Node: Controlling Array Traversal766607
-Node: Array Sorting Functions774887
-Ref: Array Sorting Functions-Footnote-1778794
-Node: Two-way I/O778988
-Ref: Two-way I/O-Footnote-1783932
-Ref: Two-way I/O-Footnote-2784111
-Node: TCP/IP Networking784193
-Node: Profiling787038
-Node: Advanced Features Summary794589
-Node: Internationalization796453
-Node: I18N and L10N797933
-Node: Explaining gettext798619
-Ref: Explaining gettext-Footnote-1803645
-Ref: Explaining gettext-Footnote-2803829
-Node: Programmer i18n803994
-Ref: Programmer i18n-Footnote-1808788
-Node: Translator i18n808837
-Node: String Extraction809631
-Ref: String Extraction-Footnote-1810764
-Node: Printf Ordering810850
-Ref: Printf Ordering-Footnote-1813632
-Node: I18N Portability813696
-Ref: I18N Portability-Footnote-1816145
-Node: I18N Example816208
-Ref: I18N Example-Footnote-1818914
-Node: Gawk I18N818986
-Node: I18N Summary819624
-Node: Debugger820963
-Node: Debugging821985
-Node: Debugging Concepts822426
-Node: Debugging Terms824282
-Node: Awk Debugging826879
-Node: Sample Debugging Session827771
-Node: Debugger Invocation828291
-Node: Finding The Bug829624
-Node: List of Debugger Commands836106
-Node: Breakpoint Control837438
-Node: Debugger Execution Control841102
-Node: Viewing And Changing Data844462
-Node: Execution Stack847820
-Node: Debugger Info849333
-Node: Miscellaneous Debugger Commands853327
-Node: Readline Support858511
-Node: Limitations859403
-Node: Debugging Summary861677
-Node: Arbitrary Precision Arithmetic862845
-Node: Computer Arithmetic864332
-Ref: Computer Arithmetic-Footnote-1868719
-Node: Math Definitions868776
-Ref: table-ieee-formats872065
-Ref: Math Definitions-Footnote-1872605
-Node: MPFR features872708
-Node: FP Math Caution874325
-Ref: FP Math Caution-Footnote-1875375
-Node: Inexactness of computations875744
-Node: Inexact representation876692
-Node: Comparing FP Values878047
-Node: Errors accumulate879011
-Node: Getting Accuracy880444
-Node: Try To Round883103
-Node: Setting precision884002
-Ref: table-predefined-precision-strings884684
-Node: Setting the rounding mode886477
-Ref: table-gawk-rounding-modes886841
-Ref: Setting the rounding mode-Footnote-1890295
-Node: Arbitrary Precision Integers890474
-Ref: Arbitrary Precision Integers-Footnote-1894247
-Node: POSIX Floating Point Problems894396
-Ref: POSIX Floating Point Problems-Footnote-1898272
-Node: Floating point summary898310
-Node: Dynamic Extensions900514
-Node: Extension Intro902066
-Node: Plugin License903331
-Node: Extension Mechanism Outline904016
-Ref: figure-load-extension904440
-Ref: figure-load-new-function905925
-Ref: figure-call-new-function906927
-Node: Extension API Description908911
-Node: Extension API Functions Introduction910361
-Node: General Data Types915228
-Ref: General Data Types-Footnote-1920921
-Node: Requesting Values921220
-Ref: table-value-types-returned921957
-Node: Memory Allocation Functions922915
-Ref: Memory Allocation Functions-Footnote-1925662
-Node: Constructor Functions925758
-Node: Registration Functions927516
-Node: Extension Functions928201
-Node: Exit Callback Functions930503
-Node: Extension Version String931751
-Node: Input Parsers932401
-Node: Output Wrappers942215
-Node: Two-way processors946731
-Node: Printing Messages948935
-Ref: Printing Messages-Footnote-1950012
-Node: Updating `ERRNO'950164
-Node: Accessing Parameters950903
-Node: Symbol Table Access952133
-Node: Symbol table by name952647
-Node: Symbol table by cookie954623
-Ref: Symbol table by cookie-Footnote-1958756
-Node: Cached values958819
-Ref: Cached values-Footnote-1962323
-Node: Array Manipulation962414
-Ref: Array Manipulation-Footnote-1963512
-Node: Array Data Types963551
-Ref: Array Data Types-Footnote-1966254
-Node: Array Functions966346
-Node: Flattening Arrays970220
-Node: Creating Arrays977072
-Node: Extension API Variables981803
-Node: Extension Versioning982439
-Node: Extension API Informational Variables984340
-Node: Extension API Boilerplate985426
-Node: Finding Extensions989230
-Node: Extension Example989790
-Node: Internal File Description990520
-Node: Internal File Ops994611
-Ref: Internal File Ops-Footnote-11006043
-Node: Using Internal File Ops1006183
-Ref: Using Internal File Ops-Footnote-11008530
-Node: Extension Samples1008798
-Node: Extension Sample File Functions1010322
-Node: Extension Sample Fnmatch1017890
-Node: Extension Sample Fork1019372
-Node: Extension Sample Inplace1020585
-Node: Extension Sample Ord1022260
-Node: Extension Sample Readdir1023096
-Ref: table-readdir-file-types1023952
-Node: Extension Sample Revout1024751
-Node: Extension Sample Rev2way1025342
-Node: Extension Sample Read write array1026083
-Node: Extension Sample Readfile1027962
-Node: Extension Sample API Tests1029062
-Node: Extension Sample Time1029587
-Node: gawkextlib1030902
-Node: Extension summary1033715
-Node: Extension Exercises1037408
-Node: Language History1038130
-Node: V7/SVR3.11039773
-Node: SVR41042093
-Node: POSIX1043535
-Node: BTL1044921
-Node: POSIX/GNU1045655
-Node: Feature History1051371
-Node: Common Extensions1064462
-Node: Ranges and Locales1065774
-Ref: Ranges and Locales-Footnote-11070391
-Ref: Ranges and Locales-Footnote-21070418
-Ref: Ranges and Locales-Footnote-31070652
-Node: Contributors1070873
-Node: History summary1076298
-Node: Installation1077667
-Node: Gawk Distribution1078618
-Node: Getting1079102
-Node: Extracting1079926
-Node: Distribution contents1081568
-Node: Unix Installation1087338
-Node: Quick Installation1087955
-Node: Additional Configuration Options1090397
-Node: Configuration Philosophy1092135
-Node: Non-Unix Installation1094486
-Node: PC Installation1094944
-Node: PC Binary Installation1096255
-Node: PC Compiling1098103
-Ref: PC Compiling-Footnote-11101102
-Node: PC Testing1101207
-Node: PC Using1102383
-Node: Cygwin1106535
-Node: MSYS1107344
-Node: VMS Installation1107858
-Node: VMS Compilation1108654
-Ref: VMS Compilation-Footnote-11109876
-Node: VMS Dynamic Extensions1109934
-Node: VMS Installation Details1111307
-Node: VMS Running1113559
-Node: VMS GNV1116393
-Node: VMS Old Gawk1117116
-Node: Bugs1117586
-Node: Other Versions1121590
-Node: Installation summary1127817
-Node: Notes1128873
-Node: Compatibility Mode1129738
-Node: Additions1130520
-Node: Accessing The Source1131445
-Node: Adding Code1132881
-Node: New Ports1139059
-Node: Derived Files1143540
-Ref: Derived Files-Footnote-11148621
-Ref: Derived Files-Footnote-21148655
-Ref: Derived Files-Footnote-31149251
-Node: Future Extensions1149365
-Node: Implementation Limitations1149971
-Node: Extension Design1151219
-Node: Old Extension Problems1152373
-Ref: Old Extension Problems-Footnote-11153890
-Node: Extension New Mechanism Goals1153947
-Ref: Extension New Mechanism Goals-Footnote-11157307
-Node: Extension Other Design Decisions1157496
-Node: Extension Future Growth1159602
-Node: Old Extension Mechanism1160438
-Node: Notes summary1162200
-Node: Basic Concepts1163386
-Node: Basic High Level1164067
-Ref: figure-general-flow1164339
-Ref: figure-process-flow1164938
-Ref: Basic High Level-Footnote-11168167
-Node: Basic Data Typing1168352
-Node: Glossary1171680
-Node: Copying1196832
-Node: GNU Free Documentation License1234388
-Node: Index1259524
+Node: Foreword42103
+Node: Preface46450
+Ref: Preface-Footnote-149320
+Ref: Preface-Footnote-249427
+Ref: Preface-Footnote-349660
+Node: History49802
+Node: Names52150
+Ref: Names-Footnote-153244
+Node: This Manual53390
+Ref: This Manual-Footnote-159219
+Node: Conventions59319
+Node: Manual History61659
+Ref: Manual History-Footnote-164650
+Ref: Manual History-Footnote-264691
+Node: How To Contribute64765
+Node: Acknowledgments66004
+Node: Getting Started70812
+Node: Running gawk73246
+Node: One-shot74436
+Node: Read Terminal75661
+Node: Long77688
+Node: Executable Scripts79204
+Ref: Executable Scripts-Footnote-181993
+Node: Comments82095
+Node: Quoting84568
+Node: DOS Quoting90074
+Node: Sample Data Files90749
+Node: Very Simple93342
+Node: Two Rules98233
+Node: More Complex100119
+Node: Statements/Lines102981
+Ref: Statements/Lines-Footnote-1107437
+Node: Other Features107702
+Node: When108633
+Ref: When-Footnote-1110389
+Node: Intro Summary110454
+Node: Invoking Gawk111337
+Node: Command Line112852
+Node: Options113643
+Ref: Options-Footnote-1129409
+Node: Other Arguments129434
+Node: Naming Standard Input132395
+Node: Environment Variables133488
+Node: AWKPATH Variable134046
+Ref: AWKPATH Variable-Footnote-1136898
+Ref: AWKPATH Variable-Footnote-2136943
+Node: AWKLIBPATH Variable137203
+Node: Other Environment Variables137962
+Node: Exit Status141453
+Node: Include Files142128
+Node: Loading Shared Libraries145716
+Node: Obsolete147143
+Node: Undocumented147840
+Node: Invoking Summary148107
+Node: Regexp149773
+Node: Regexp Usage151232
+Node: Escape Sequences153265
+Node: Regexp Operators159365
+Ref: Regexp Operators-Footnote-1166799
+Ref: Regexp Operators-Footnote-2166946
+Node: Bracket Expressions167044
+Ref: table-char-classes169061
+Node: Leftmost Longest172001
+Node: Computed Regexps173303
+Node: GNU Regexp Operators176700
+Node: Case-sensitivity180402
+Ref: Case-sensitivity-Footnote-1183292
+Ref: Case-sensitivity-Footnote-2183527
+Node: Regexp Summary183635
+Node: Reading Files185104
+Node: Records187198
+Node: awk split records187930
+Node: gawk split records192844
+Ref: gawk split records-Footnote-1197383
+Node: Fields197420
+Ref: Fields-Footnote-1200218
+Node: Nonconstant Fields200304
+Ref: Nonconstant Fields-Footnote-1202540
+Node: Changing Fields202742
+Node: Field Separators208674
+Node: Default Field Splitting211378
+Node: Regexp Field Splitting212495
+Node: Single Character Fields215845
+Node: Command Line Field Separator216904
+Node: Full Line Fields220116
+Ref: Full Line Fields-Footnote-1220624
+Node: Field Splitting Summary220670
+Ref: Field Splitting Summary-Footnote-1223801
+Node: Constant Size223902
+Node: Splitting By Content228508
+Ref: Splitting By Content-Footnote-1232581
+Node: Multiple Line232621
+Ref: Multiple Line-Footnote-1238510
+Node: Getline238689
+Node: Plain Getline240900
+Node: Getline/Variable243540
+Node: Getline/File244687
+Node: Getline/Variable/File246071
+Ref: Getline/Variable/File-Footnote-1247672
+Node: Getline/Pipe247759
+Node: Getline/Variable/Pipe250442
+Node: Getline/Coprocess251573
+Node: Getline/Variable/Coprocess252825
+Node: Getline Notes253564
+Node: Getline Summary256356
+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: Print268130
+Node: Print Examples269587
+Node: Output Separators272366
+Node: OFMT274384
+Node: Printf275738
+Node: Basic Printf276523
+Node: Control Letters278094
+Node: Format Modifiers282078
+Node: Printf Examples288085
+Node: Redirection290567
+Node: Special FD297406
+Ref: Special FD-Footnote-1300563
+Node: Special Files300637
+Node: Other Inherited Files301253
+Node: Special Network302253
+Node: Special Caveats303114
+Node: Close Files And Pipes304065
+Ref: Close Files And Pipes-Footnote-1311244
+Ref: Close Files And Pipes-Footnote-2311392
+Node: Output Summary311542
+Node: Output Exercises312538
+Node: Expressions313218
+Node: Values314403
+Node: Constants315079
+Node: Scalar Constants315759
+Ref: Scalar Constants-Footnote-1316618
+Node: Nondecimal-numbers316868
+Node: Regexp Constants319868
+Node: Using Constant Regexps320393
+Node: Variables323531
+Node: Using Variables324186
+Node: Assignment Options326096
+Node: Conversion327971
+Node: Strings And Numbers328495
+Ref: Strings And Numbers-Footnote-1331559
+Node: Locale influences conversions331668
+Ref: table-locale-affects334413
+Node: All Operators335001
+Node: Arithmetic Ops335631
+Node: Concatenation338136
+Ref: Concatenation-Footnote-1340955
+Node: Assignment Ops341061
+Ref: table-assign-ops346044
+Node: Increment Ops347322
+Node: Truth Values and Conditions350760
+Node: Truth Values351843
+Node: Typing and Comparison352892
+Node: Variable Typing353685
+Node: Comparison Operators357337
+Ref: table-relational-ops357747
+Node: POSIX String Comparison361262
+Ref: POSIX String Comparison-Footnote-1362334
+Node: Boolean Ops362472
+Ref: Boolean Ops-Footnote-1366951
+Node: Conditional Exp367042
+Node: Function Calls368769
+Node: Precedence372649
+Node: Locales376317
+Node: Expressions Summary377948
+Node: Patterns and Actions380522
+Node: Pattern Overview381642
+Node: Regexp Patterns383321
+Node: Expression Patterns383864
+Node: Ranges387644
+Node: BEGIN/END390750
+Node: Using BEGIN/END391512
+Ref: Using BEGIN/END-Footnote-1394249
+Node: I/O And BEGIN/END394355
+Node: BEGINFILE/ENDFILE396669
+Node: Empty399570
+Node: Using Shell Variables399887
+Node: Action Overview402163
+Node: Statements404490
+Node: If Statement406338
+Node: While Statement407836
+Node: Do Statement409864
+Node: For Statement411006
+Node: Switch Statement414161
+Node: Break Statement416549
+Node: Continue Statement418590
+Node: Next Statement420415
+Node: Nextfile Statement422795
+Node: Exit Statement425425
+Node: Built-in Variables427828
+Node: User-modified428961
+Ref: User-modified-Footnote-1436641
+Node: Auto-set436703
+Ref: Auto-set-Footnote-1450070
+Ref: Auto-set-Footnote-2450275
+Node: ARGC and ARGV450331
+Node: Pattern Action Summary454535
+Node: Arrays456962
+Node: Array Basics458291
+Node: Array Intro459135
+Ref: figure-array-elements461099
+Ref: Array Intro-Footnote-1463623
+Node: Reference to Elements463751
+Node: Assigning Elements466201
+Node: Array Example466692
+Node: Scanning an Array468450
+Node: Controlling Scanning471466
+Ref: Controlling Scanning-Footnote-1476655
+Node: Numeric Array Subscripts476971
+Node: Uninitialized Subscripts479156
+Node: Delete480773
+Ref: Delete-Footnote-1483517
+Node: Multidimensional483574
+Node: Multiscanning486669
+Node: Arrays of Arrays488258
+Node: Arrays Summary493019
+Node: Functions495124
+Node: Built-in495997
+Node: Calling Built-in497075
+Node: Numeric Functions499063
+Ref: Numeric Functions-Footnote-1503887
+Ref: Numeric Functions-Footnote-2504244
+Ref: Numeric Functions-Footnote-3504292
+Node: String Functions504561
+Ref: String Functions-Footnote-1528033
+Ref: String Functions-Footnote-2528162
+Ref: String Functions-Footnote-3528410
+Node: Gory Details528497
+Ref: table-sub-escapes530278
+Ref: table-sub-proposed531798
+Ref: table-posix-sub533162
+Ref: table-gensub-escapes534702
+Ref: Gory Details-Footnote-1535534
+Node: I/O Functions535685
+Ref: I/O Functions-Footnote-1542786
+Node: Time Functions542933
+Ref: Time Functions-Footnote-1553402
+Ref: Time Functions-Footnote-2553470
+Ref: Time Functions-Footnote-3553628
+Ref: Time Functions-Footnote-4553739
+Ref: Time Functions-Footnote-5553851
+Ref: Time Functions-Footnote-6554078
+Node: Bitwise Functions554344
+Ref: table-bitwise-ops554906
+Ref: Bitwise Functions-Footnote-1559214
+Node: Type Functions559383
+Node: I18N Functions560532
+Node: User-defined562177
+Node: Definition Syntax562981
+Ref: Definition Syntax-Footnote-1568387
+Node: Function Example568456
+Ref: Function Example-Footnote-1571373
+Node: Function Caveats571395
+Node: Calling A Function571913
+Node: Variable Scope572868
+Node: Pass By Value/Reference575856
+Node: Return Statement579366
+Node: Dynamic Typing582350
+Node: Indirect Calls583279
+Ref: Indirect Calls-Footnote-1594583
+Node: Functions Summary594711
+Node: Library Functions597410
+Ref: Library Functions-Footnote-1601028
+Ref: Library Functions-Footnote-2601171
+Node: Library Names601342
+Ref: Library Names-Footnote-1604802
+Ref: Library Names-Footnote-2605022
+Node: General Functions605108
+Node: Strtonum Function606211
+Node: Assert Function609231
+Node: Round Function612555
+Node: Cliff Random Function614096
+Node: Ordinal Functions615112
+Ref: Ordinal Functions-Footnote-1618177
+Ref: Ordinal Functions-Footnote-2618429
+Node: Join Function618640
+Ref: Join Function-Footnote-1620411
+Node: Getlocaltime Function620611
+Node: Readfile Function624352
+Node: Shell Quoting626322
+Node: Data File Management627723
+Node: Filetrans Function628355
+Node: Rewind Function632414
+Node: File Checking633799
+Ref: File Checking-Footnote-1635127
+Node: Empty Files635328
+Node: Ignoring Assigns637307
+Node: Getopt Function638858
+Ref: Getopt Function-Footnote-1650318
+Node: Passwd Functions650521
+Ref: Passwd Functions-Footnote-1659372
+Node: Group Functions659460
+Ref: Group Functions-Footnote-1667363
+Node: Walking Arrays667576
+Node: Library Functions Summary669179
+Node: Library Exercises670580
+Node: Sample Programs671860
+Node: Running Examples672630
+Node: Clones673358
+Node: Cut Program674582
+Node: Egrep Program684312
+Ref: Egrep Program-Footnote-1691816
+Node: Id Program691926
+Node: Split Program695570
+Ref: Split Program-Footnote-1699016
+Node: Tee Program699144
+Node: Uniq Program701931
+Node: Wc Program709352
+Ref: Wc Program-Footnote-1713600
+Node: Miscellaneous Programs713692
+Node: Dupword Program714905
+Node: Alarm Program716936
+Node: Translate Program721740
+Ref: Translate Program-Footnote-1726304
+Node: Labels Program726574
+Ref: Labels Program-Footnote-1729923
+Node: Word Sorting730007
+Node: History Sorting734077
+Node: Extract Program735913
+Node: Simple Sed743445
+Node: Igawk Program746507
+Ref: Igawk Program-Footnote-1760833
+Ref: Igawk Program-Footnote-2761034
+Ref: Igawk Program-Footnote-3761156
+Node: Anagram Program761271
+Node: Signature Program764333
+Node: Programs Summary765580
+Node: Programs Exercises766773
+Ref: Programs Exercises-Footnote-1770904
+Node: Advanced Features770995
+Node: Nondecimal Data772943
+Node: Array Sorting774533
+Node: Controlling Array Traversal775230
+Ref: Controlling Array Traversal-Footnote-1783561
+Node: Array Sorting Functions783679
+Ref: Array Sorting Functions-Footnote-1787571
+Node: Two-way I/O787765
+Ref: Two-way I/O-Footnote-1792709
+Ref: Two-way I/O-Footnote-2792895
+Node: TCP/IP Networking792977
+Node: Profiling795849
+Node: Advanced Features Summary803402
+Node: Internationalization805335
+Node: I18N and L10N806815
+Node: Explaining gettext807501
+Ref: Explaining gettext-Footnote-1812530
+Ref: Explaining gettext-Footnote-2812714
+Node: Programmer i18n812879
+Ref: Programmer i18n-Footnote-1817745
+Node: Translator i18n817794
+Node: String Extraction818588
+Ref: String Extraction-Footnote-1819719
+Node: Printf Ordering819805
+Ref: Printf Ordering-Footnote-1822591
+Node: I18N Portability822655
+Ref: I18N Portability-Footnote-1825104
+Node: I18N Example825167
+Ref: I18N Example-Footnote-1827967
+Node: Gawk I18N828039
+Node: I18N Summary828677
+Node: Debugger830016
+Node: Debugging831038
+Node: Debugging Concepts831479
+Node: Debugging Terms833336
+Node: Awk Debugging835911
+Node: Sample Debugging Session836803
+Node: Debugger Invocation837323
+Node: Finding The Bug838707
+Node: List of Debugger Commands845182
+Node: Breakpoint Control846514
+Node: Debugger Execution Control850206
+Node: Viewing And Changing Data853570
+Node: Execution Stack856935
+Node: Debugger Info858573
+Node: Miscellaneous Debugger Commands862590
+Node: Readline Support867782
+Node: Limitations868674
+Node: Debugging Summary870771
+Node: Arbitrary Precision Arithmetic871939
+Node: Computer Arithmetic873355
+Ref: table-numeric-ranges876956
+Ref: Computer Arithmetic-Footnote-1877815
+Node: Math Definitions877872
+Ref: table-ieee-formats881159
+Ref: Math Definitions-Footnote-1881763
+Node: MPFR features881868
+Node: FP Math Caution883539
+Ref: FP Math Caution-Footnote-1884589
+Node: Inexactness of computations884958
+Node: Inexact representation885906
+Node: Comparing FP Values887261
+Node: Errors accumulate888334
+Node: Getting Accuracy889767
+Node: Try To Round892426
+Node: Setting precision893325
+Ref: table-predefined-precision-strings894009
+Node: Setting the rounding mode895803
+Ref: table-gawk-rounding-modes896167
+Ref: Setting the rounding mode-Footnote-1899621
+Node: Arbitrary Precision Integers899800
+Ref: Arbitrary Precision Integers-Footnote-1904704
+Node: POSIX Floating Point Problems904853
+Ref: POSIX Floating Point Problems-Footnote-1908729
+Node: Floating point summary908767
+Node: Dynamic Extensions910959
+Node: Extension Intro912511
+Node: Plugin License913777
+Node: Extension Mechanism Outline914574
+Ref: figure-load-extension915002
+Ref: figure-register-new-function916482
+Ref: figure-call-new-function917486
+Node: Extension API Description919472
+Node: Extension API Functions Introduction920922
+Node: General Data Types925758
+Ref: General Data Types-Footnote-1931445
+Node: Memory Allocation Functions931744
+Ref: Memory Allocation Functions-Footnote-1934574
+Node: Constructor Functions934670
+Node: Registration Functions936404
+Node: Extension Functions937089
+Node: Exit Callback Functions939385
+Node: Extension Version String940633
+Node: Input Parsers941283
+Node: Output Wrappers951098
+Node: Two-way processors955614
+Node: Printing Messages957818
+Ref: Printing Messages-Footnote-1958895
+Node: Updating `ERRNO'959047
+Node: Requesting Values959787
+Ref: table-value-types-returned960515
+Node: Accessing Parameters961473
+Node: Symbol Table Access962704
+Node: Symbol table by name963218
+Node: Symbol table by cookie965198
+Ref: Symbol table by cookie-Footnote-1969337
+Node: Cached values969400
+Ref: Cached values-Footnote-1972904
+Node: Array Manipulation972995
+Ref: Array Manipulation-Footnote-1974093
+Node: Array Data Types974132
+Ref: Array Data Types-Footnote-1976789
+Node: Array Functions976881
+Node: Flattening Arrays980735
+Node: Creating Arrays987622
+Node: Extension API Variables992389
+Node: Extension Versioning993025
+Node: Extension API Informational Variables994926
+Node: Extension API Boilerplate996014
+Node: Finding Extensions999830
+Node: Extension Example1000390
+Node: Internal File Description1001162
+Node: Internal File Ops1005229
+Ref: Internal File Ops-Footnote-11016887
+Node: Using Internal File Ops1017027
+Ref: Using Internal File Ops-Footnote-11019410
+Node: Extension Samples1019683
+Node: Extension Sample File Functions1021207
+Node: Extension Sample Fnmatch1028809
+Node: Extension Sample Fork1030291
+Node: Extension Sample Inplace1031504
+Node: Extension Sample Ord1033179
+Node: Extension Sample Readdir1034015
+Ref: table-readdir-file-types1034871
+Node: Extension Sample Revout1035682
+Node: Extension Sample Rev2way1036273
+Node: Extension Sample Read write array1037014
+Node: Extension Sample Readfile1038953
+Node: Extension Sample Time1040048
+Node: Extension Sample API Tests1041397
+Node: gawkextlib1041888
+Node: Extension summary1044538
+Node: Extension Exercises1048220
+Node: Language History1048942
+Node: V7/SVR3.11050599
+Node: SVR41052780
+Node: POSIX1054225
+Node: BTL1055614
+Node: POSIX/GNU1056348
+Node: Feature History1061977
+Node: Common Extensions1075068
+Node: Ranges and Locales1076392
+Ref: Ranges and Locales-Footnote-11081031
+Ref: Ranges and Locales-Footnote-21081058
+Ref: Ranges and Locales-Footnote-31081292
+Node: Contributors1081513
+Node: History summary1087053
+Node: Installation1088422
+Node: Gawk Distribution1089378
+Node: Getting1089862
+Node: Extracting1090686
+Node: Distribution contents1092328
+Node: Unix Installation1098098
+Node: Quick Installation1098715
+Node: Additional Configuration Options1101146
+Node: Configuration Philosophy1102886
+Node: Non-Unix Installation1105237
+Node: PC Installation1105695
+Node: PC Binary Installation1107021
+Node: PC Compiling1108869
+Ref: PC Compiling-Footnote-11111890
+Node: PC Testing1111995
+Node: PC Using1113171
+Node: Cygwin1117286
+Node: MSYS1118109
+Node: VMS Installation1118607
+Node: VMS Compilation1119399
+Ref: VMS Compilation-Footnote-11120621
+Node: VMS Dynamic Extensions1120679
+Node: VMS Installation Details1122363
+Node: VMS Running1124615
+Node: VMS GNV1127456
+Node: VMS Old Gawk1128190
+Node: Bugs1128660
+Node: Other Versions1132564
+Node: Installation summary1138777
+Node: Notes1139833
+Node: Compatibility Mode1140698
+Node: Additions1141480
+Node: Accessing The Source1142405
+Node: Adding Code1143841
+Node: New Ports1150013
+Node: Derived Files1154495
+Ref: Derived Files-Footnote-11159970
+Ref: Derived Files-Footnote-21160004
+Ref: Derived Files-Footnote-31160600
+Node: Future Extensions1160714
+Node: Implementation Limitations1161320
+Node: Extension Design1162568
+Node: Old Extension Problems1163722
+Ref: Old Extension Problems-Footnote-11165239
+Node: Extension New Mechanism Goals1165296
+Ref: Extension New Mechanism Goals-Footnote-11168656
+Node: Extension Other Design Decisions1168845
+Node: Extension Future Growth1170953
+Node: Old Extension Mechanism1171789
+Node: Notes summary1173551
+Node: Basic Concepts1174737
+Node: Basic High Level1175418
+Ref: figure-general-flow1175690
+Ref: figure-process-flow1176289
+Ref: Basic High Level-Footnote-11179518
+Node: Basic Data Typing1179703
+Node: Glossary1183031
+Node: Copying1208189
+Node: GNU Free Documentation License1245745
+Node: Index1270881

End Tag Table