Lines Matching +refs:po +refs:check +refs:for +refs:pending +refs:edit

3 @c %**start of header (This is for running Texinfo on a region.)
6 @c %**end of header (This is for running Texinfo on a region.)
31 @set SUBTITLE A User's Guide for GNU Awk
83 Some comments on the layout for TeX.
118 for the @value{VERSION}.@value{PATCHLEVEL} (or later) version of the GNU
136 funds for GNU development.''
140 @c Comment out the "smallbook" for technical review. Saves
150 @c Uncomment this for the release. Leaving it off saves paper
168 included for their instructional value. They have been tested with care
169 but are not guaranteed for any particular purpose. The publisher does not
198 @c This one is correct for gawk 3.1.0 from the FSF
206 @c Thanks to Bob Chassell for directions on doing dedications.
212 @center @i{To Miriam, for making me complete.}
214 @center @i{To Chana, for the joy you bring us.}
216 @center @i{To Rivka, for the exponential increase.}
218 @center @i{To Nachum, for the added dimension.}
220 @center @i{To Malka, for the new beginning.}
273 * Advanced Features:: Stuff for advanced users, specific to
290 * GNU Free Documentation License:: The license for this @value{DOCUMENT}.
317 * Sample Data Files:: Sample data files for use in the
381 * Special FD:: Special files for I/O.
382 * Special Process:: Special files for process information.
383 * Special Network:: Special files for network communications.
384 * Special Caveats:: Things to watch out for.
391 * Variables:: Variables give names to values for later
440 * Switch Statement:: Switch/case evaluation for conditional
459 * Scanning an Array:: A variation of the @code{for} statement. It
476 * String Functions:: Functions for string manipulation, such as
482 * I/O Functions:: Functions for files and shell commands.
483 * Time Functions:: Functions for dealing with timestamps.
484 * Bitwise Functions:: Functions for bitwise operations.
485 * I18N Functions:: Functions for string translation.
491 * Function Caveats:: Things to watch out for.
496 * Programmer i18n:: Features for the programmer.
497 * Translator i18n:: Features for the translator.
506 * TCP/IP Networking:: Using @command{gawk} for network
513 * AWKPATH Variable:: Searching directories for @command{awk}
523 * Assert Function:: A function for assertions in @command{awk}
525 * Round Function:: A function for rounding if @code{sprintf}
528 * Ordinal Functions:: Functions for using characters as numbers
532 * Data File Management:: Functions for managing command-line data
534 * Filetrans Function:: A function for handling data file
536 * Rewind Function:: A function for rereading the current file.
538 * Empty Files:: Checking for zero-length files.
540 * Getopt Function:: A function for processing command-line
542 * Passwd Functions:: Functions for getting user information.
543 * Group Functions:: Functions for getting group information.
565 * Igawk Program:: A wrapper for @command{awk} that includes
592 * PC Compiling:: Compiling @command{gawk} for MS-DOS, Windows32,
596 * PC Dynamic:: Compiling @command{gawk} for dynamic
598 * Cygwin:: Building and running @command{gawk} for
604 * VMS POSIX:: Alternate instructions for VMS POSIX.
627 * Internal File Ops:: The code for internal file operations.
637 @c dedication for Info file
639 @center To Miriam, for making me complete.
641 @center To Chana, for the joy you bring us.
643 @center To Rivka, for the exponential increase.
645 @center To Nachum, for the added dimension.
647 @center To Malka, for the new beginning.
680 The best way to get a new @command{awk} was to @command{ftp} the source code for
687 Linux, and you can download binaries or source code for almost
724 Those looking for something new can try out @command{gawk}'s
737 I recently experimented with an algorithm that for
779 Writing single-use programs for these tasks in languages such as C, C++, or Pascal
798 @cindex @command{awk}, uses for
821 @cindex @command{gawk}, uses for
828 Extract bits and pieces of data for processing
846 Implementations of the @command{awk} language are available for many
849 implementation of @command{awk} called @command{gawk} (which stands for
871 @cindex recipe for a programming language
872 @cindex programming language, recipe for
902 The specification for @command{awk} in the POSIX Command Language
905 designers provided feedback for the POSIX specification.
913 help from me, thoroughly reworked @command{gawk} for compatibility
919 In May of 1997, J@"urgen Kahrs felt the need for network access
921 features to do this for @command{gawk}. At that time, he also
929 for a complete list of those who made important contributions to @command{gawk}.
945 for the new
947 Others have an @command{oawk} version for the ``old @command{awk}''
948 language and plain @command{awk} for the new one. Still others only
950 use @command{gawk} for their @command{awk} implementation!}
954 All in all, this makes it difficult for you to know which version of
956 I can give here is to check your local documentation. Look for @command{awk},
957 @command{oawk}, and @command{nawk}, as well as for @command{gawk}.
992 the POSIX standard for @command{awk} are noted.
997 You should also ignore the many cross-references; they are for the
998 expert user and for the online Info version of the document.
1041 for getting most things done in a program.
1044 describes how to write patterns for matching records, actions for
1059 describes special features in @command{gawk} for translating program
1096 future directions for @command{gawk} development.
1099 provides some very cursory background material for those who
1162 @c fakenode --- for prepinfo
1205 The GNU@footnote{GNU stands for ``GNU's not Unix.''}
1216 for your reference
1218 The GPL applies to the C language source code for @command{gawk}.
1237 system for Intel 80386, DEC Alpha, Sun SPARC, IBM S/390, and other
1245 (There are three other freely available, Unix-like operating systems for
1248 of @command{gawk} for their versions of @command{awk}.)
1253 source code for the @value{DOCUMENT} comes with @command{gawk}; anyone
1255 copies as they like. (Take a moment to check the Free Documentation
1276 for Edition 0.13 of December 1991.
1278 of the manual for Edition 0.13.
1340 @xref{Bugs}, for information on submitting
1363 Many people need to be thanked for their assistance in producing this
1366 manual. The paper @cite{A Supplemental Document for @command{awk}} by John W.@:
1373 I would like to acknowledge Richard M.@: Stallman, for his vision of a
1374 better world and for his courage in founding the FSF and starting the
1405 He also deserves special thanks for
1415 Dr.@: Bert and Rita Schreiber of Detroit for large amounts of quiet vacation
1435 Drepper, provided invaluable help and feedback for the design of the
1468 David and I would like to thank Brian Kernighan of Bell Laboratories for
1469 invaluable assistance during the testing and debugging of @command{gawk}, and for
1475 significant editorial help for this @value{DOCUMENT} for the
1482 I must thank my wonderful wife, Miriam, for her patience through
1483 the many versions of this project, for her proofreading,
1484 and for sharing me with the computer.
1485 I would like to thank my parents for their love, and for the grace with
1487 Finally, I also must acknowledge my gratitude to G-d, for the many opportunities
1488 He has sent my way, as well as for the gifts He has given me with which to
1556 The basic function of @command{awk} is to search files for lines (or other
1562 @cindex @command{awk}, uses for
1563 @c comma here is NOT for secondary
1581 an advanced feature that we will ignore for now.
1583 pattern to search for and one action to perform
1600 * Sample Data Files:: Sample data files for use in the @command{awk}
1671 a single argument for @command{awk}, and allow @var{program} to be more
1676 This format is also useful for running short or medium-sized @command{awk}
1677 programs from shell scripts, because it avoids the need for a separate
1678 file for the @command{awk} program. A self-contained shell script is more
1688 @c Removed for gawk 3.1, doesn't really add anything here.
1756 Now is the time for all good men
1757 @print{} Now is the time for all good men
1775 @command{awk} to use that file for its program, you type:
1785 from the file @var{source-file}. Any @value{FN} can be used for
1814 for programs that are provided on the @command{awk} command line.
1876 @c fakenode --- for prepinfo
1907 A @dfn{comment} is some text that is included in a program for the sake
1910 programming languages have provisions for comments, as programs are
1939 quote for the entire program. As a result, usually the shell
1951 It therefore prompts with the secondary prompt, waiting for more input.
1969 @cindex quoting, rules for
1981 @cindex shells, quoting, rules for
1982 @cindex Bourne shell, quoting rules for
1991 quoted items. The shell turns everything into one argument for
2010 for an example of what happens if you try.
2064 @cindex quoting, tricks for
2085 Judge for yourself which of these two is the more readable.
2106 @section @value{DDF}s for the Examples
2119 bulletin board, its phone number, the board's baud rate(s), and a code for
2183 file into a file for use with @command{awk}
2185 for more information). Using this information, create your own
2192 for an @command{awk} program that extracts these @value{DF}s from
2193 @file{gawk.texi}, the Texinfo source file for this Info file.
2200 input file @file{BBS-list} for the character string @samp{foo} (a
2217 is the pattern to search for. This type of pattern is called a
2239 for @emph{every} input line. If the action is omitted, the default
2257 your own @value{FN}s for @file{data}.
2309 awk 'BEGIN @{ for (i = 1; i <= 7; i++)
2410 in @file{BBS-list} was printed twice, once for each rule.
2435 @ref{Statements/Lines}, for an
2472 @samp{Nov} for its sixth field, the action @samp{sum += $5} is
2540 for clarity, we have kept most statements short in the sample programs
2546 split a string constant using backslash continuation. Thus, for maximum
2556 with the C shell.} It works for @command{awk} programs in files and
2557 for one-shot programs, @emph{provided} you are using a POSIX-compliant
2629 language; it was added for consistency with the treatment of statements
2641 In addition, @command{awk} provides a number of built-in functions for doing
2643 @command{gawk} provides built-in functions for working with timestamps,
2644 performing bit manipulation, and for runtime string translation.
2654 @cindex @command{awk}, uses for
2656 you might wonder how @command{awk} could be useful for you. By using
2659 complex output. The @command{awk} language is very useful for producing
2669 edit-compile-test-debug cycle of software development.
2672 retargetable assembler for eight-bit microprocessors (@pxref{Glossary}, for
2673 more information), and a microcode assembler for a special-purpose Prolog
2684 better facilities for system programming and for managing the complexity
2769 @code{while}, @code{for}, and @code{do} statements.
2904 The octal value @var{nnn}, where @var{nnn} stands for 1 to 3 digits
2905 between @samp{0} and @samp{7}. For example, the code for the ASCII ESC
2913 The hexadecimal value @var{hh}, where @var{hh} stands for a sequence
2924 A literal slash (necessary for regexp constants only).
2933 A literal double quote (necessary for string constants only).
2962 for both string constants and regexp constants. This happens very early,
2968 for the special operators listed in
2976 @c fakenode --- for prepinfo
3009 @c fakenode --- for prepinfo
3010 @subheading Advanced Notes: Escape Sequences for Metacharacters
3011 @cindex metacharacters, escape sequences for
3019 @cindex dark corner, escape sequences, for metacharacters
3048 sequences and that are not listed in the table stand for themselves:
3148 Parentheses are used for grouping in regular expressions, as in
3161 applies the @samp{*} symbol to the preceding @samp{h} and looks for matches
3248 stand for themselves when there is nothing in the regexp that precedes them.
3272 might be equivalent to @samp{[aBbCcDdxXyYz]}, for example. To obtain
3301 of the POSIX specification for Extended Regular Expressions (EREs).
3308 A character class is a special notation for describing
3397 character. They can also have several characters that are equivalent for
3413 Locale-specific names for a list of
3426 @strong{Caution:} The library functions that @command{gawk} uses for regular
3442 @cindex regular expressions, operators, for words
3458 letter, digit, or underscore. Think of it as shorthand for
3466 Think of it as shorthand for
3504 @cindex buffers, operators for
3505 @cindex regular expressions, operators, for buffers
3506 @cindex operators, string-matching, for buffers
3535 for @command{awk}. They are provided for compatibility with other
3546 method of using @samp{\y} for the GNU @samp{\b} appears to be the
3606 list---for example, @samp{[Ww]}. However, this can be cumbersome if
3653 to set @code{IGNORECASE} just for the pattern of
3662 case-sensitivity on or off for all the rules at once.
3668 a program case-insensitive without having to edit it.
3683 for use with European languages.
3724 for more information on these functions.
3726 Understanding this principle is also important for regexp-based record
3781 For example, @code{/\*/} is a regexp constant for a literal @samp{*}.
3792 constants,'' for several reasons:
3813 @c fakenode --- for prepinfo
3819 character to be used inside a character list for a dynamic regexp:
3841 occur often in practice, but it's worth noting for future reference.
3920 This makes it more convenient for programs to work on the parts of a record.
3950 The @command{awk} utility divides the input for your @command{awk}
3961 @cindex separators, for records
3966 A different character can be used for the record separator by
4031 Note that the entry for the @samp{camelot} BBS is not split.
4044 for the @samp{core} BBS; the newline separating them in the output
4049 @cindex separators, for records
4061 Using an unusual character such as @samp{/} for the record separator
4084 @xref{Multiple Line}, for more details.
4097 @cindex separators, for records, regular expressions as
4138 @xref{Simple Sed}, for a more useful example
4157 @c fakenode --- for prepinfo
4165 to do in a general way, such that a program always works for arbitrary
4169 You might think that for text files, the @sc{nul} character, which
4171 value to use for @code{RS} in this case:
4179 character for the record separator.
4215 considered whitespace for separating fields.} other characters, such as
4220 The purpose of fields is to make it more convenient for you to refer to
4283 looks for @samp{foo} in @emph{the entire record} and prints the first
4284 field and the last field for each matching input record:
4328 hours of operation (the fourth field) for every line of the file
4373 Then it prints the original and new values for field three.
4379 for the computer to do arithmetic on it. The number resulting
4417 represents the total number of parcels shipped for a particular month.
4451 for more information about @command{awk}'s @code{if-else} statements.
4453 for more information about the @samp{!=} operator.)
4544 @command{awk} scans the input record for character sequences that
4644 regular expression. In this case, each match in the record for the regular
4656 is an @dfn{escape sequence} that stands for a TAB;
4658 for the complete list of similar escape sequences.)
4732 > for (i = 1; i <= NF; i = i + 1)
4778 The value used for the argument to @option{-F} is processed in exactly the
4792 Because @samp{\} is used for quoting in the shell, @command{awk} sees
4793 @samp{-F\\}. Then @command{awk} processes the @samp{\\} for escape
4795 a single @samp{\} to use for the field separator.
4864 the entries for users who have no password:
4907 @c fakenode --- for prepinfo
4952 @c fakenode --- for prepinfo
4971 do it for you. E.g., @samp{FS = "[c]"}. In this case, @code{IGNORECASE}
4995 @command{gawk} @value{PVERSION} 2.13 introduced a facility for dealing with
4997 data of this nature arises in the input for old Fortran programs where
4999 anticipate the use of their output as input for other programs.
5007 this is awkward and inefficient for a large number of fields.
5080 cards. These cards are then processed to count the votes for any particular
5083 program for processing such data could use the @code{FIELDWIDTHS} feature
5093 @code{FS} for field splitting again. Use @samp{FS = FS} to make this happen,
5112 for an example of such a function).
5181 The original motivation for this special exception was probably to provide
5190 regexp for that single character. For example, if the field
5246 @xref{Labels Program}, for a more realistic
5318 In the following examples, @var{command} stands for a string value that
5373 decommented input, such as searching for matches of a regular
5395 @c comma before using is NOT for tertiary
5405 read-a-line-and-check-each-rule loop of @command{awk} never sees it.
5476 @c Thanks to Paul Eggert for initial wording here
5479 @samp{$}; for example, @samp{getline < dir "/" file} is ambiguous
5486 @c comma before using is NOT for tertiary
5498 output, except for records that say @w{@samp{@@include @var{filename}}}.
5527 @xref{Igawk Program}, for a program
5543 For example, the following program copies its input to its output, except for
5562 @samp{@@execute} lines appear in the input, the command is run for
5605 @c Thanks to Paul Eggert for initial wording here
5608 @samp{$}---for example, @samp{@w{"echo "} "date" | getline} is ambiguous
5615 @c comma before using is NOT for tertiary
5637 @c Thanks to Paul Eggert for initial wording here
5640 @samp{$}; for example, @samp{@w{"echo "} "date" | getline @var{var}} is ambiguous
5649 @c comma before using is NOT for tertiary
5661 for processing and then read the results back.
5690 @c comma before using is NOT for tertiary
5750 is likely to be a source for
5796 for simple output, and the @code{printf} statement
5797 for fancier formatting.
5901 together in the output, with no space. The reason for this is that
5958 complicated when there are many columns to fix. Counting spaces for two
6054 number to a string for printing.
6076 @section Using @code{printf} Statements for Fancier Printing
6085 specify the width to use for each item, as well as various
6086 formatting choices for numbers (such as what output base to use, whether to
6161 65} outputs the letter @samp{A}. (The output for a string value is
6166 (The @samp{%i} specification is for compatibility with ISO C.)
6170 for example:
6211 are floating-point; it is provided primarily for compatibility with C.)
6227 When using the integer format-control letters for values that are
6236 @subsection Modifiers for @code{printf} Formats
6272 It is in fact a @command{gawk} extension, intended for use in translating
6299 says to always supply a sign for numeric conversions, even if the data
6303 Use an ``alternate form'' for certain control letters.
6305 For @samp{%x} and @samp{%X}, supply a leading @samp{0x} or @samp{0X} for
6377 capability (for example, @code{"%*.*s"}) is supported. Instead of
6463 It wasn't necessary to specify a width for the phone numbers because
6491 used for the column elements ensures that the headings
6506 @code{printf} statement to line up the headings and table data for the
6532 to a coprocess. They are all shown for the @code{print} statement,
6533 but they work identically for @code{printf}:
6597 This isn't the best style, since COMMAND is assigned for each
6599 alone for now and let's hope no-one notices.
6613 in an @command{awk} script run periodically for system maintenance:
6631 for more information.
6654 for a more complete discussion.
6663 It is a common error to use @samp{>} redirection for the first @code{print}
6664 to a file, and then to use @samp{>>} for subsequent output:
6677 use @samp{>} for all the @code{print} statements, since the output file
6698 @c fakenode --- for prepinfo
6721 It then sends the list to the shell for execution.
6735 * Special FD:: Special files for I/O.
6736 * Special Process:: Special files for process information.
6737 * Special Network:: Special files for network communications.
6738 * Special Caveats:: Things to watch out for.
6742 @subsection Special Files for Standard Descriptors
6752 already available to them for reading and writing. These are known as
6757 is typically used for writing error messages; the reason there are two separate
6789 @command{gawk} provides special @value{FN}s for accessing the three standard
6792 then it directly uses the stream that the @value{FN} stands for.
6793 These special @value{FN}s work for all operating systems that @command{gawk}
6821 are aliases for @file{/dev/fd/0}, @file{/dev/fd/1}, and @file{/dev/fd/2},
6838 @subsection Special Files for Process-Related Information
6840 @cindex files, for process information
6841 @cindex process information, files for
6895 as well as for I/O redirections within an @command{awk} program.
6910 @subsection Special Files for Network Communications
6911 @cindex networks, support for
6912 @cindex TCP/IP, support for
6925 for making a networking connection.
6926 These @value{FN}s are used with the @samp{|&} operator for communicating
6929 This is an advanced feature, mentioned here only for completeness.
6976 for output actually writes on file descriptor 4, and not on a new
7007 Similarly, when a file or pipe is opened for output, the @value{FN} or
7062 programs. Here are some of the reasons for closing an output file:
7120 runs out of file descriptors for more pipelines.
7128 more importantly, the file descriptor for the pipe
7158 @c fakenode --- for prepinfo
7190 system call. See the system manual pages for information on
7205 @c 4/27/2003: Commenting this out for now, given the above
7207 The return value for closing a pipeline is particularly useful.
7228 Currently, in @command{gawk}, this only works for commands
7260 * Variables:: Variables give names to values for later use.
7304 A @dfn{numeric constant} stands for a number. This number can be an
7402 for more information.
7420 @c fakenode --- for prepinfo
7429 always used. This has particular consequences for conversion of
7458 operators, a regexp constant merely stands for the regexp that is to be
7497 This code is ``obviously'' testing @code{$1} for a match against the regexp
7523 Constant regular expressions are also used as the first argument for
7571 Variables are ways of storing values at one point in your program for
7603 record). @xref{Built-in Variables}, for a list of the built-in variables.
7646 (@xref{Options}, for more information about
7657 prints the value of field number @code{n} for all input records. Before
7675 Command-line arguments are made available for explicit examination by
7678 @command{awk} processes the values of command-line assignments for escape
7710 If, for some reason, you need to force a number to be converted to a
7760 of @code{OFMT} for converting numbers to strings. @code{OFMT}
7766 However, these semantics for @code{OFMT} are something to keep in mind if you must
7771 for more information on the @code{print} statement.
7777 characters. The locale also affects numeric formats. In particular, for @command{awk}
7784 point when reading the @command{awk} program source code, and for command-line
7786 However, when interpreting input data, for @code{print} and @code{printf} output,
7787 and for number to string conversion, the local decimal point character is used.
7804 The @samp{en_DK} locale is for English in Denmark, where the comma acts as
7872 the value 0.75. (It is a common mistake, especially for C programmers,
7920 for exponentiation.
7981 In particular, the order of evaluation of expressions used for concatenation
7993 before or after the value of @code{a} is retrieved for producing the
7996 @c see test/nasty.awk for a worse example
8158 Assignments may be used anywhere an expression is called for. For
8192 # Thanks to Pat Rankin for this example
8195 for (x in foo)
8199 for (x in bar)
8211 and see @ref{Numeric Functions}, for more information).
8291 @c fakenode --- for prepinfo
8345 are convenient abbreviations for very common operations.
8351 The operator used for adding one is written @samp{++}. It can be used to increment
8409 @c fakenode --- for prepinfo
8425 What happens for something like the following?
8446 The result for the first example may be 12 or 13, and for the second, it
8450 not anything that you can rely upon for portability.
8466 Many programming languages have a special representation for the concepts
8522 like a number---for example, @code{@w{" +2"}}. This concept is used
8523 for determining the type of a variable.
8570 @c thanks to Karl Berry, kb@cs.umb.edu, for major help with TeX tables
8580 % each row. The template for the first column breaks down like this:
8584 % # -- replaced by the text (for instance, `STRNUM', in the last row).
8597 % The \omit tells TeX to skip inserting the template for this column on
8631 Thus, for example, the string constant @w{@code{" +3.14"}}
8633 and is @emph{never} treated as number for comparison
8639 revision. The revised standard's rules for typing and comparison are
8640 the same as just described for @command{gawk}.}
8642 @dfn{Comparison expressions} compare strings or numbers for
8798 @code{/@var{regexp}/} is an abbreviation for the following comparison expression:
8804 One special place where @code{/foo/} is @emph{not} an abbreviation for
8838 @code{do}, and @code{for} statements
8919 The @samp{!} operator is often useful for changing the sense of a flag
8997 for more information about arrays.
9015 A @dfn{function} is a name for a particular calculation.
9017 ask for it by name at any point in the program. For
9023 of these. @xref{Built-in}, for a list of built-in
9025 functions for use in your program.
9027 for instructions on how to do this.
9033 provide the raw materials for the function's calculations.
9065 @xref{Built-in}, for full details. If arguments
9115 operator groups first, except for the assignment, conditional, and
9220 parentheses. Such combinations (for example, @samp{print foo > a ? b : c}),
9287 The pattern-action rules and the statements available for use
9338 Special patterns for you to supply startup or cleanup actions for your
9498 for the following record. Then the range pattern goes back to checking
9508 It is possible for a pattern to be turned on and off by the same
9510 executed for just that record.
9567 All the patterns described so far are for matching input records.
9569 They supply startup and cleanup actions for @command{awk} programs.
9571 action for these rules because there is no current record when they run.
9601 for the report. There is no need to use the @code{BEGIN} rule to
9623 Multiple @code{BEGIN} and @code{END} rules are useful for writing
9630 @xref{Options}, for more information on
9633 for a number of useful library functions.
9670 In fact, @command{gawk} does preserve the value of @code{$0} for use in
9722 hold a pattern that the @command{awk} program searches for.
9773 the program---for printing, as an array subscript, or for any other
9789 @command{awk} what to do once a match for the pattern is found. Thus,
9802 @cindex separators, for statements in actions
9833 (@code{if}, @code{for}, @code{while}, and @code{do}) as well as a few
9840 or @code{for} statement.
9899 * Switch Statement:: Switch/case evaluation for conditional
10059 occasionally is there a real use for a @code{do} statement.
10062 @subsection The @code{for} Statement
10063 @cindex @code{for} statement
10065 The @code{for} statement makes it more convenient to count iterations of a
10066 loop. The general form of the @code{for} statement looks like this:
10069 for (@var{initialization}; @var{condition}; @var{increment})
10075 arbitrary @command{awk} expressions, and @var{body} stands for any
10078 The @code{for} statement starts by executing @var{initialization}.
10087 awk '@{ for (i = 1; i <= 3; i++)
10101 their assignments as separate statements preceding the @code{for} loop.)
10115 for (i = 1; i <= 100; i *= 2)
10120 parentheses following the @code{for} keyword may be omitted. Thus,
10121 @w{@samp{for (; x > 0;)}} is equivalent to @w{@samp{while (x > 0)}}. If the
10125 In most cases, a @code{for} loop is an abbreviation for a @code{while}
10140 inside the loop. Changing a @code{for} statement to a @code{while}
10144 The @command{awk} language has a @code{for} statement in addition to a
10145 @code{while} statement because a @code{for} loop is often both less work to
10152 There is an alternate version of the @code{for} loop, for iterating over
10156 for (i in array)
10162 for more information on this version of the @code{for} loop.
10176 for more information.
10180 are checked for a match in the order they are defined. If no suitable
10218 next @code{case} until execution halts. In the above example, for
10230 The @code{break} statement jumps out of the innermost @code{for},
10239 for (div = 2; div*div <= num; div++)
10250 immediately @dfn{breaks out} of the containing @code{for} loop. This means
10256 Th following program illustrates how the @var{condition} of a @code{for}
10264 for (div = 2; ; div++) @{
10303 @code{for}, @code{while}, and @code{do} loops. It skips
10308 The @code{continue} statement in a @code{for} loop directs @command{awk} to
10310 increment-expression of the @code{for} statement. The following program
10315 for (x = 0; x <= 20; x++) @{
10325 This program prints all the numbers from 0 to 20---except for 5, for
10328 @code{for} loop from the previous example with the following @code{while} loop:
10371 further rules are executed for the current record, and the rest of the
10383 think of this loop as a @code{for} statement whose body contains the
10464 reserved for closing files, pipes, and coprocesses that are
10471 for a user-defined function that simulates the @code{nextfile}
10490 words (@samp{next file}) for the @code{nextfile} statement.
10521 rule stops the execution of any further automatic rules for the current
10527 to nonzero before the @code{exit} statement and check that variable in
10530 for an example that does this.
10534 status code for the @command{awk} process. If no argument is supplied,
10569 Most @command{awk} variables are available to use for your own
10607 On non-POSIX systems, this variable specifies use of binary mode for all I/O.
10650 overrides the use of @code{FS} for field splitting.
10651 @xref{Constant Size}, for more information.
10688 If @command{gawk} is using @code{FIELDWIDTHS} for field splitting,
10744 strings (@pxref{Conversion}) for
10749 also used @code{OFMT} to specify the format for converting numbers to
10781 The ability for @code{RS} to be a regular expression
10802 This variable is used for internationalization of programs at the
10803 @command{awk} level. It sets the default text domain for specially
10804 marked string constants in the source text, as well as for the
10846 > for (i = 0; i < ARGC; i++)
10869 @xref{ARGC and ARGV}, for information
10876 Every time @command{gawk} opens a new @value{DF} for processing, it sets
10910 On such systems, the @code{ENVIRON} array is empty (except for
10918 If a system error occurs during a redirection for @code{getline},
10919 during a read for @code{getline}, or during a @code{close} operation,
11017 through @code{"group@var{N}"} for some @var{N}. @var{N} is the number of
11019 to test for these elements
11060 @c fakenode --- for prepinfo
11069 change these variables and their new values are incremented for
11105 > for (i = 0; i < ARGC; i++)
11128 @print{} for (i = 0; i < ARGC; i++)
11164 @ref{Tee Program}, for examples
11172 for (i = 1; i < ARGC; i++) @{
11199 into @code{ARGV} for the @command{awk} program to deal with. As soon
11200 as it sees an unknown option, @command{gawk} stops looking for other
11228 for sorting an array based on its indices.
11236 of names that may be used for naming variables, arrays, and functions
11246 * Scanning an Array:: A variation of the @code{for} statement. It
11264 for storing groups of related strings or numbers.
11279 declaration causes a contiguous block of memory to be allocated for that
11285 array, because it has room only for as many elements as given in
11297 @c from Karl Berry, much thanks for the help.
11429 element. For example, @code{foo[4.3]} is an expression for the element
11513 for (x = 1; x <= max; x++)
11554 for (x = 1; x <= max; x++)
11566 executes once for each element of an array. In other languages, where
11571 So @command{awk} has a special kind of @code{for} statement for scanning
11575 for (@var{var} in @var{array})
11581 This loop executes @var{body} once for each index in @var{array} that the
11584 @cindex arrays, @code{for} statement and
11585 @cindex @code{for} statement, in arrays
11586 The following program uses this form of the @code{for} statement. The
11594 for more information on the built-in function @code{length}.
11597 # Record a 1 for each word that is used at least once
11599 for (i = 1; i <= NF; i++)
11605 for (x in used)
11616 for a more detailed example of this type.
11624 the loop body; it is not predictable whether the @code{for} loop will
11648 for (i in frequencies)
11654 Once an element is deleted, a subsequent @code{for} statement to scan the array
11655 does not report that element and the @code{in} operator to check for
11703 out an array:@footnote{Thanks to Michael Brennan for pointing this out.}
11734 it is converted to a string value before being used for subscripting
11762 According to the rules for conversions
11769 for (i = 1; i <= maxsub; i++)
11774 has an additional consequence for array indexing.
11779 This means, for example, that
11809 > for (i = lines-1; i >= 0; --i)
11823 The issue here is that subscripts for @command{awk} arrays are @emph{always}
11832 for (i = lines - 1; i >= 0; --i)
11897 used for single dimensional arrays. Write the whole sequence of indices
11914 for (x = 1; x <= NF; x++)
11919 for (x = 1; x <= max_nf; x++) @{
11920 for (y = max_nr; y >= 1; --y)
11952 There is no special @code{for} statement for scanning a
11961 the scanning @code{for} statement
11968 for (combined in array) @{
11984 Sooner or later, the @code{for} statement finds that index and does an
12005 The order in which an array is scanned with a @samp{for (i in array)}
12009 While this can be educational for exploring different sorting algorithms,
12014 for sorting arrays. For example:
12019 for (i = 1; i <= n; i++)
12040 for (i = 1; i <= n; i++)
12052 @code{asort}, except that the index values are used for sorting, and
12060 for (i = 1; i <= n; i++)
12074 for (i in data) @{
12079 for (i = 1; i <= n; i++)
12102 affects sorting for both @code{asort} and @code{asorti}.
12119 Besides the built-in functions, @command{awk} has provisions for
12133 @dfn{Built-in} functions are always available for
12137 but are summarized here for your convenience.
12143 * String Functions:: Functions for string manipulation, such as
12145 * I/O Functions:: Functions for files and shell commands.
12146 * Time Functions:: Functions for dealing with timestamps.
12147 * Bitwise Functions:: Functions for bitwise operations.
12148 * I18N Functions:: Functions for string translation.
12173 In some cases, arguments can be omitted. The defaults for omitted
12193 is called with a value of four for its actual parameter.
12194 The order of evaluation of the expressions used for the function's
12282 between one and @var{n}. This program prints a new random number for
12305 from run to run. This is convenient for debugging, but if you want
12313 for generating random numbers to the value @var{x}.
12329 date and time of day are used for a seed. This is the way to get random
12358 sorted using @command{gawk}'s normal rules for comparing values
12412 This searches the string @var{in} for the first occurrence of the string
12445 version of the standard. Therefore, for programs to be maximally portable,
12450 The @code{match} function searches @var{string} for the
12459 @ref{Computed Regexps}, for a
12461 implications for writing your program correctly.
12466 for @code{match}, the order is the same as for the @samp{~} operator:
12495 This program looks for lines that match the regular expression stored in
12553 There may not be subscripts for the start and index for every parenthesized
12555 should be tested for with the @code{in} operator
12614 @ref{Computed Regexps}, for a
12616 and the implications for writing your program correctly.
12660 works only for decimal data, not for octal or hexadecimal.@footnote{Unless
12662 @xref{Nondecimal Data}, for more information.}
12671 It searches this value, which is treated as a string, for the
12680 @ref{Computed Regexps}, for a
12682 implications for writing your program correctly.
12708 stands for the precise substring that was matched by @var{regexp}. (If
12752 still searches for the pattern and returns zero or one, but the result of
12775 substrings it can find. The @samp{g} in @code{gsub} stands for
12784 Kingdom} for all input records.
12795 @code{gsub}, it searches the target string @var{target} for matches of
12838 passed directly to @code{print} for printing.
12947 At both levels, @command{awk} looks for a defined set of characters that
12948 can come after a backslash. At the lexical level, it looks for the
12950 Thus, for every @samp{\} that @command{awk} processes at the runtime
12952 When a character that is not valid for an escape sequence follows the
12954 @samp{\} and put the next character into the string. Thus, for
12965 @c Thank to Karl Berry for help with the TeX stuff.
12970 % But then we need character for escape and tab.
13012 says that @code{sub} and @code{gsub} look for either a @samp{\} or an @samp{&}
13016 @c thanks to Karl Berry for formatting this table
13021 % But then we need character for escape and tab.
13048 following character, but for anything other than @samp{\} and @samp{&},
13064 Because of the problems just listed, proposed text for the revised standard
13073 % But then we need character for escape and tab.
13102 @command{gawk} 3.0 and 3.1 follow these proposed POSIX rules for @code{sub} and
13111 However, it was too late to change @command{gawk} for the 3.1 release.
13114 The rules for @code{gensub} are considerably simpler. At the runtime
13125 % But then we need character for escape and tab.
13153 and the special cases for @code{sub} and @code{gsub},
13157 @c fakenode --- for prepinfo
13168 This is particularly important for the @code{sub}, @code{gsub},
13189 Close the file @var{filename} for input or output. Alternatively, the
13190 argument may be a shell command that was used for creating a coprocess, or
13191 for redirecting to or from a pipe; then the coprocess or pipe is closed.
13193 for more information.
13207 file opened for writing or a shell command for redirecting output to
13215 for it to be worthwhile to send the data to the output device.
13231 is to allow no argument at all. In this case, the buffer for the
13233 (@w{@code{""}}) as the argument. In this case, the buffers for
13246 a file or pipe that was opened for reading (such as with @code{getline}),
13285 program is interactive, @code{system} is useful for cranking up large
13291 @c fakenode --- for prepinfo
13302 @c Thanks to Walter.Mecky@dresdnerbank.de for this example, and for
13335 @c fakenode --- for prepinfo
13342 The @code{fflush} function provides explicit control over output buffering for
13362 @code{system} should flush any pending output. The following program:
13423 useful reports, @command{gawk} provides the following functions for
13428 for simple time-related operations in shell scripts.}
13456 for example, an hour of @minus{}1 means 1 hour before midnight.
13463 whether daylight savings time is in effect for the specified time.
13501 returned string, while substituting date and time values for format
13606 The method for determining the week number is as specified by ISO 8601.
13644 ``Alternate representations'' for the specifications
13676 for systems that are not yet fully standards-compliant.
13775 @i{I can explain it for you, but I can't understand it for you.}@*
13930 for (; bits != 0; bits = rshift(bits, 1))
13952 for (; bits != 0; bits = rshift(bits, 1))
14009 decimal and octal values for the same numbers
14026 @command{gawk} provides facilities for internationalizing @command{awk} programs.
14030 for the full story.
14037 text domain @var{domain} for locale category @var{category}.
14038 The default value for @var{domain} is the current value of @code{TEXTDOMAIN}.
14039 The default value for @var{category} is @code{"LC_MESSAGES"}.
14043 This function returns the plural form used for @var{number} of the
14045 @var{domain} for locale category @var{category}. @var{string1} is the
14048 The default value for @var{domain} is the current value of @code{TEXTDOMAIN}.
14049 The default value for @var{category} is @code{"LC_MESSAGES"}.
14054 @command{gawk} will look for message translation files, in case they
14061 @code{bindtextdomain} returns the current binding for the
14083 * Function Caveats:: Things to watch out for.
14149 use for arguments and how many you intend to use as local variables. It is
14158 names have been taken away for the local variables. All other variables
14189 Instead it defines a rule that, for each record, concatenates the value
14246 for (i in a)
14322 call for the arguments. Each time the call is executed, these
14341 a variable as the expression for the argument, but the called function
14379 copied. Instead, the array itself is made available for direct manipulation
14448 can also be used to return a value for use in the rest of the @command{awk}
14463 Sometimes, you want to write a function for what it does, not for
14470 for the largest number among the elements of an array:
14475 for (i in vec) @{
14500 for (i in vec) @{
14509 for(i = 1; i <= NF; i++)
14578 uses for internationalization, as well as how
14589 * Programmer i18n:: Features for the programmer.
14590 * Translator i18n:: Features for the translator.
14605 @dfn{Localization} means providing the data necessary for an
14608 used for printing error messages, the language used to read
14640 through the source for all of @command{guide}'s components
14641 and marks each string that is a candidate for translation.
14642 For example, @code{"`-F': option required"} is a good candidate for translation.
14655 collected into a portable object file (@file{guide.po}),
14658 The original (usually English) messages serve as the key for
14661 @cindex @code{.po} files
14662 @cindex files, @code{.po}
14666 For each language with a translator, @file{guide.po}
14674 Each language's @file{.po} file is converted into a binary
14738 for different types of locale-related information.
14744 Text messages. This is the default category for @code{gettext}
14772 Numeric information, such as which characters to use for the decimal
14774 use a comma every three decimal places and a period for the decimal
14802 @command{gawk} provides the following variables and functions for
14813 @cindex strings, for localization
14816 are candidates for translation at runtime.
14822 text domain @var{domain} for locale category @var{category}.
14823 The default value for @var{domain} is the current value of @code{TEXTDOMAIN}.
14824 The default value for @var{category} is @code{"LC_MESSAGES"}.
14826 If you supply a value for @var{category}, it must be a string equal to
14838 of the @code{dcgettext} function is purposely different from the order for
14840 chosen to be simple and to allow for reasonable @command{awk}-style
14845 This built-in function returns the plural form used for @var{number} of the
14847 @var{domain} for locale category @var{category}. @var{string1} is the
14850 The default value for @var{domain} is the current value of @code{TEXTDOMAIN}.
14851 The default value for @var{category} is @code{"LC_MESSAGES"}.
14853 The same remarks as for the @code{dcgettext} function apply.
14862 @code{gettext} looks for @file{.mo} files, in case they
14869 @code{bindtextdomain} returns the current binding for the
14931 file in a private directory for testing. This is done
14950 for an example program showing the steps to create
14956 @cindex @code{.po} files
14957 @cindex files, @code{.po}
14961 be extracted to create the initial @file{.po} file.
14965 @command{gawk}'s @option{--gen-po} command-line option extracts
14968 rearrange the order for @code{printf} arguments at runtime
14982 @cindex @code{--gen-po} option
14988 @cindex @code{--gen-po} option
14992 First, use the @option{--gen-po} command-line option to create
14993 the initial @file{.po} file:
14996 $ gawk --gen-po -f guide.awk > guide.po
15000 When run with @option{--gen-po}, @command{gawk} does not execute your
15009 for the full list of steps to go through to create and test
15010 translations for @command{guide}.
15018 Format strings for @code{printf} and @code{sprintf}
15020 present a special problem for translation.
15024 @c line broken here only for smallbook format
15030 A possible German translation for this might be:
15139 following it.@footnote{This is good fodder for an ``Obfuscated
15182 However, since the positional specifications are primarily for use in
15199 bindtextdomain(".") # for testing
15208 Run @samp{gawk --gen-po} to create the @file{.po} file:
15211 $ gawk --gen-po -f guide.awk > guide.po
15218 @c file eg/data/guide.po
15230 This original portable object file is saved and reused for each language
15235 appear in the @file{guide.po} file.
15244 $ cp guide.po guide-mellow.po
15245 @var{Add translations to} guide-mellow.po @dots{}
15253 @c file eg/data/guide-mellow.po
15269 The directory layout shown here is standard for GNU @code{gettext} on
15277 @cindex @code{.po} files, converting to @code{.mo}
15278 @cindex files, @code{.po}, converting to @code{.mo}
15279 @cindex @code{.mo} files, converting from @code{.po}
15280 @cindex files, @code{.mo}, converting from @code{.po}
15287 @file{.po} file to machine-readable @file{.mo} file.
15293 $ msgfmt guide-mellow.po
15306 If the three replacement functions for @code{dcgettext}, @code{dcngettext}
15347 for more information.
15380 it for performance.
15390 * TCP/IP Networking:: Using @command{gawk} for network programming.
15406 @c line break here for small book format
15488 send data to a separate program for
15493 # write the data for processing
15509 for example, @file{/tmp} will not do, as another user might happen
15560 known as @dfn{deadlock}, where each process is waiting for the
15591 for (i = n; i > 0; i--)
15611 Beginning with @command{gawk} 3.1.2, you may use Pseudo-ttys (ptys) for
15619 command = "sort -nr" # command, saved in variable for convenience
15632 @section Using @command{gawk} for Network Programming
15665 @samp{udp}, or @samp{raw}, for a TCP, UDP, or raw IP connection,
15666 respectively. The use of TCP is recommended for most applications.
15707 Because this topic is extensive, the use of @command{gawk} for
15716 for a much more complete introduction and discussion, as well as
15739 for two-way communications. The operating system's portal mechanism
15795 for (i = 1; i <= 3; i++)
15846 6 for (i = 1; i <= 3; i++) @{
15874 This example illustrates many of the basic rules for profiling output.
15897 the count for an @code{if}-@code{else} statement shows how many times
15899 To the right of the opening left brace for the @code{if}'s body
15901 The count for the @code{else}
15904 @cindex loops, count for header
15906 The count for a loop header (such as @code{for}
16036 @code{INT} and @code{QUIT} signals for producing the profile and, in
16056 It then proceeds to cover how @command{gawk} searches for source files,
16069 * AWKPATH Variable:: Searching directories for @command{awk}
16084 one or more program files. Here are templates for both of them; items
16137 Each long option for @command{gawk} has a corresponding
16191 for compatibility but otherwise ignored by
16266 Having a list of all global variables is a good way to look for
16274 @item -W gen-po
16275 @itemx --gen-po
16276 @cindex @code{--gen-po} option
16281 output for all string constants that have been marked for translation.
16283 for information about this option.
16364 The synonym @code{func} for the keyword @code{function} is not
16409 @value{FN} for the profile file.
16413 counts for each statement in the program in the left margin, and function
16414 call counts for each function.
16443 Prints version information for this particular copy of @command{gawk}.
16447 It is also useful for bug reports
16458 character (@code{"\t"}). This is true only for @option{--traditional} and not
16459 for @option{--posix}
16466 useful for creating libraries of @command{awk} functions. These functions
16483 input for your source code; it allows you to easily mix command-line
16498 Many GNU programs look for this environment variable to turn on
16522 Having @env{POSIXLY_CORRECT} set is not recommended for daily use,
16523 but it is good for testing the portability of your programs to other
16566 The variable values given on the command line are processed for escape
16580 The variable assignment feature is most useful for assigning to variables
16582 output formats before scanning the @value{DF}s. It is also useful for
16592 Given the variable assignment feature, the @option{-F} option for setting
16594 strictly necessary. It remains for historical compatibility.
16600 @cindex search paths, for source files
16607 implementations, you must supply a precise path name for each program
16611 directories (called the @dfn{search path}), one by one, looking for a
16623 though.} (Programs written for use by
16627 The search path feature is particularly useful for building libraries
16631 would have to be typed for each file.
16637 This is true for both @option{--traditional} and @option{--posix}.
16674 @c update this section for each release!
16682 The use of @samp{next file} (two words) for @code{nextfile} was deprecated
16758 @xref{Statements/Lines}, for a fuller
16761 You can insert newlines after the @samp{;} in @code{for} loops.
16765 @var{init} and @var{increment} parts of a @code{for} loop. This is another
16770 then the associative @code{for} loop will go through the array
16772 The comparison used for sorting is simple string comparison;
16793 The @option{-F} option for changing the value of @code{FS}
16796 assignment feature; it remains only for backward compatibility.
16811 Part II shows how to use @command{awk} and @command{gawk} for problem solving.
16812 There is lots of code here for you to read and learn from.
16848 provide a good-sized body of code for you to read,
16859 presents a program that you can use to extract the source code for
16861 for this @value{DOCUMENT}.
16867 @ref{How To Contribute}, for more information.
16873 Rewriting these programs for different implementations of awk is pretty straightforward.
16885 @c 12/2000: Thanks to Nelson Beebe for pointing out the output issue.
16909 * Data File Management:: Functions for managing command-line data
16911 * Getopt Function:: A function for processing command-line
16913 * Passwd Functions:: Functions for getting user information.
16914 * Group Functions:: Functions for getting group information.
16930 @cindex variables, global, for library functions
16934 preserve state information between calls to the function---for example,
16940 When writing a library function, you should try to choose names for your
16944 often use variable names like these for their own purposes.
16956 indicate what function or set of functions use the variables---for example,
16961 convention is used equally well for variable names and for private
16965 provide some basis for this discussion.}
16968 available for use by a main program, it is a good convention to start that
16969 variable's name with a capital letter---for
16980 option is useful for verifying this.} If this is not done, the variable
17020 * Assert Function:: A function for assertions in @command{awk}
17022 * Round Function:: A function for rounding if @code{sprintf} does
17025 * Ordinal Functions:: Functions for using characters as numbers and
17129 However, if @code{nextfile} is called for the last record in the file,
17146 features for little reason leads to larger, slower programs that are
17203 The C language makes it possible to turn the condition into a string for use
17282 most likely causing the program to hang as it waits for input.
17312 you should check what your system does. The following function does
17370 for randomness by showing no structure.''
17400 uses the current seed as input for the calculation.
17413 @code{ord}, which takes a character and returns the numeric value for that
17459 for (i = low; i <= high; i++) @{
17477 for country-specific characters. If your system uses these extensions,
17509 # for (;;) @{
17519 An obvious improvement to these functions is to move the code for the
17521 written this way initially for ease of development.
17523 function. It is commented out for production use.
17566 for (i = start + 1; i <= end; i++)
17577 separator for the strings. If the value is equal to @code{SUBSEP},
17581 be nice if @command{awk} had an assignment operator for concatenation.
17582 The lack of an explicit operator for concatenation makes string operations
17594 provide the minimum functionality necessary for dealing with the time of day
17681 A more general design for the @code{gettimeofday} function would have
17694 This @value{SECTION} presents functions that are useful for managing
17698 * Filetrans Function:: A function for handling data file transitions.
17699 * Rewind Function:: A function for rereading the current file.
17701 * Empty Files:: Checking for zero-length files.
17731 # Give the user a hook for filename transitions
17755 automatically changes for each new @value{DF}. The current @value{FN} is
17758 it is necessary to call @code{endfile} for the old file. Because
17762 @code{_oldfilename} and calls @code{beginfile} for the file.
17764 initialized to the null string, this rule executes correctly even for the
17767 The program also supplies an @code{END} rule to do the final processing for
17815 Another request for a new built-in function was for a @code{rewind}
17843 for (i = ARGC; i > ARGIND; i--)
17875 for a function version of @code{nextfile}.
17878 @subsection Checking for Readable @value{DDF}s
17905 for (i = 1; i < ARGC; i++) @{
17961 for (Argind++; Argind < ARGIND; Argind++)
17969 for (Argind++; Argind <= ARGIND; Argind++)
17978 more empty files were skipped. The action then calls @code{zerofile} for
17986 condition of the @code{for} loop uses the @samp{<=} operator,
17999 for (i = 1; i < ARGC; i++)
18013 for (Argind++; Argind < ARGIND; Argind++)
18023 for (Argind++; Argind <= ARGIND; Argind++)
18039 Some users have suggested an additional command-line option for @command{gawk}
18046 # noassign.awk --- library file to avoid the need for a
18060 for (i = 1; i < argc; i++)
18116 Modern Unix systems provide a C function named @code{getopt} for processing
18121 @code{getopt} processes the command-line arguments for option letters.
18169 arguments for @command{awk}:
18211 necessary for accessing individual characters
18243 # ? for unrecognized option
18255 for any program, and particularly for library functions.
18282 The next thing to check for is the end of the options. A @option{--}
18289 perhaps a bit of overkill; it checks for a @samp{-} followed by anything
18323 obtained with @code{substr}. It is saved in @code{Optopt} for the main
18384 @code{Opterr} is set to one, since the default behavior is for @code{getopt}
18401 for (; Optind < ARGC; Optind++)
18462 @value{SECTION} presents a suite of functions for retrieving information from the
18464 for a similar suite that retrieves information from the group database.
18475 and several C language subroutines for obtaining user information.
18476 The primary function is @code{getpwent}, for ``get password entry.''
18494 @c Use old style function header for portability to old systems (SunOS, HP/UX).
18564 we cast it to @code{long} for all cases.)
18621 With that introduction, following is a group of functions for getting user
18626 @c Answer: return foo[key] returns "" if key not there, no need to check with `in'.
18688 The variable @code{_pw_inited} is used for efficiency; @code{_pw_init}
18704 field-splitting mechanism later. The test can only be true for
18801 @command{awk} program, the check of @code{_pw_inited} could be moved out of
18838 for accessing the information.
18891 for (i = 0; g->gr_mem[i] != NULL; i++) @{
18926 we cast it to @code{long} for all cases.)
18933 for those group ID numbers.
18953 for those group ID numbers.
18971 Here are the functions for obtaining information from the group database.
18978 # group.awk --- functions for dealing with the group file
18989 @c line break on _gr_init for smallbook
19022 for (i = 1; i <= n; i++)
19053 @code{$0}, and then sets @code{FS} and @code{RS} to the correct values for
19063 database for the same group. This is common when a group has a large number
19076 a leading comma. It also doesn't check that there is a @code{$4}.)
19194 presenting a potpourri of @command{awk} programs for your reading
19235 @file{cut.awk}), @var{options} are any command-line options for the
19253 @section Reinventing Wheels for Fun and Profit
19261 very concise and simple. This is true because @command{awk} does so much for you.
19265 purpose is to illustrate @command{awk} language programming for ``real world''
19305 The options for @command{cut} are:
19410 " for delimiter\n", Optarg) > "/dev/stderr"
19423 for (i = 1; i < Optind; i++)
19430 a single space (@code{@w{" "}}) for the value of @code{FS} is
19453 print "cut: needs list for -c or -f" > "/dev/stderr"
19466 and into an array. Then, for each element of the array, it looks to
19480 for (i = 1; i <= n; i++) @{
19490 for (k = g[1]; k <= g[2]; k++)
19511 for @code{FIELDWIDTHS} is @code{@w{"8 6 1 6 14"}}. This yields five
19527 for (i = 1; i <= n; i++) @{
19584 for (i = 1; i <= nfields; i++) @{
19610 @subsection Searching for Regular Expressions in Files
19613 @cindex regular expressions, searching for
19615 @cindex searching, files for regular expressions
19617 @cindex files, searching for regular expressions
19619 The @command{egrep} utility searches files for patterns. It uses regular
19730 for (i = 1; i < Optind; i++)
19897 use this style. You can decide for yourself if you like writing
19935 The code is repetitive. The entry in the user database for the real user ID
19937 Similar code is used for the effective user ID number and the group
20002 for (i = 1; ("group" i) in PROCINFO; i++) @{
20022 The test in the @code{for} loop is worth noting.
20024 indices @code{"group1"} through @code{"group@var{N}"} for some
20062 preceded with a minus; e.g., @samp{-500} for files with 500 lines in them
20076 is used as the prefix for the output @value{FN}s:
20125 @code{s1} and @code{s2} track the current suffixes for the @value{FN}. If
20130 @c else on separate line here for page breaking
20186 which isn't true for EBCDIC systems.
20240 for (i = 1; i < ARGC; i++)
20260 executed for each line of input. The body of the rule simply prints the
20268 for (i in copy)
20271 for (i in copy)
20282 for (i in copy)
20291 tested for each record and for each output file. By duplicating the loop
20292 body, the @samp{if} is only tested once for each input record. If there are
20303 for (i in copy)
20327 The options for @command{uniq} are:
20430 # this messes us up for things like -5
20446 for (i = 1; i < Optind; i++)
20505 executed only for the very first line of data. It sets @code{last} equal to
20590 input. If there are multiple files, it also prints total counts for all
20608 since @command{awk} does a lot of the work for us; it splits lines into
20661 for (i = 1; i < Optind; i++)
20696 for the file that was just read. It relies on @code{beginfile} to reset the
20697 numbers for the following @value{DF}:
20700 @c NEXT ED: make order for += be lines, words, chars
20721 There is one rule that is executed for each line. It adds the length of
20725 in its length. Next, @code{lines} is incremented for each line read,
20740 Finally, the @code{END} rule simply prints the totals for all the files:
20781 * Igawk Program:: A wrapper for @command{awk} that includes
20789 @cindex words, duplicate, searching for
20790 @cindex searching, for words
20801 and looks for adjacent occurrences of the same word. It also saves the last
20802 word on a line (in the variable @code{prev}) for comparison with the first
20807 so that, for example, ``The'' and ``the'' compare equal to each other.
20844 for (i = 2; i <= NF; i++)
20855 @cindex insomnia, cure for
20927 # set defaults for once we reach the desired time
20970 # how long to sleep for
20983 for the given number of seconds. If the exit status is not zero,
20986 message in a loop, again using @command{sleep} to delay for however many
20997 for (i = 1; i <= count; i++) @{
21018 often used to map uppercase letters into lowercase for further processing:
21037 ``to'' list is used for the remaining characters in the ``from'' list.
21083 Finally, the processing rule simply calls @code{translate} for each record:
21101 # the last character in `to' is used for the rest of `from'.
21107 for (i = 1; i <= lt; i++)
21110 for (; i <= lf; i++)
21112 for (i = 1; i <= lf; i++) @{
21245 for (i = 1; i <= Nlines; i += 10) @{
21248 for (j = 0; j < 5; j++) @{
21258 for (i in line)
21270 for (i = 1; i <= n; i++)
21272 for (; i <= 5; i++)
21296 also demonstrates the @samp{for @var{index} in @var{array}} mechanism.
21304 for (i = 1; i <= NF; i++)
21309 for (word in freq)
21317 first rule, because it has an empty pattern, is executed for every input line.
21368 for (i = 1; i <= NF; i++)
21373 for (word in freq)
21405 for (word in freq)
21414 See the general operating system documentation for more information on how
21451 # Thanks to Byron Rakitzis for the general idea
21470 for (i = 1; i <= count; i++)
21476 This program also provides a foundation for generating other useful
21505 are the top level nodes for a large number of @command{awk} programs.
21563 The example programs in the online Texinfo source for @cite{@value{TITLE}}
21650 redirection for printing the contents, keeping open file management
21653 The @samp{for} loop does the work. It reads lines using @code{getline}
21692 for (;;) @{
21708 for (i = 2; i <= n; i++) @{
21725 This makes it easy to mix program text and explanatory prose for the same
21734 @c function lb put on same line for page breaking. sigh
21770 Here, @samp{s/old/new/g} tells @command{sed} to look for the regexp
21777 arguments: the pattern to look for and the text to replace it with. Any
21788 # Thanks to Michael Brennan for the idea
21833 The idea is to have @code{RS} be the pattern to look for. @command{gawk}
21847 The @code{BEGIN} rule handles the setup, checking for the right number
21883 @cindex libraries of @command{awk} functions, example program for using
21885 @cindex functions, library, example program for using
21931 @command{awk} source code for later, when the expanded program is run.
21959 This program uses shell variables extensively; for storing command line arguments,
21960 the text of the @command{awk} program that will expand the user's program, for the
21961 user's original program, and for the expanded program. Doing so removes some
22132 An alternative way to test for the file's existence would be to call
22148 for (i = 1; i <= ndirs; i++) @{
22173 for (i = 1; i <= ndirs; i++) @{
22187 The next thing to check is if the file is included already. The
22189 file and it tracks this information for us. If the file is
22202 for (; stackptr >= 0; stackptr--) @{
22237 The shell processes the contents of the here document for variable and command substitution
22294 Using @samp{@@include} even for the files named with @option{-f} makes building
22300 in the @code{pathto} function when testing for the
22301 file's accessibility for use with the main program simplifies things
22308 place. It is not necessary to call out to a separate loop for processing
22315 of the @command{sh} language, making it harder to follow for those who
22330 @cindex search paths, for source files
22332 @cindex source files, search path for
22334 @cindex files, source, search path for
22358 statements for the desired library functions.
22411 (This implementation was the basis for @command{awk} in Berkeley Unix,
22414 for their @command{awk}.)
22446 The requirement for @samp{;} to separate rules on a line
22507 Redirection of input for the @code{getline} function
22538 The @option{-v} option for assigning variables before program execution begins
22543 The @option{--} option for terminating command-line options.
22548 @c GNU, for ANSI C compat
22551 A defined return value for the @code{srand} built-in function
22556 for case translation
22560 A cleaner specification for the @samp{%c} format-control letter in the
22584 The POSIX Command Language and Utilities standard for @command{awk} (1992)
22589 The use of @option{-W} for implementation-specific options
22593 The use of @code{CONVFMT} for controlling the conversion of numbers
22625 The synonym @code{func} for the keyword @code{function} is not
22667 The @code{fflush} built-in function for flushing buffered output
22677 The use of @code{func} as an abbreviation for @code{function}
22690 originally developed for @command{gawk}:
22703 The ability for @code{FS} and for the third
22720 I've tried to follow this general order, esp. for the 3.0 and 3.1 sections:
22748 The @env{AWKPATH} environment variable for specifying a path search for
22770 The @code{systime} and @code{strftime} built-in functions for obtaining
22776 for both the source code and at runtime
22784 The @option{-W posix} option for full POSIX compliance
22792 The @code{next file} statement for skipping to the next @value{DF}
22822 The @option{--source} option for mixing command-line and library-file
22841 Full support for both POSIX and GNU regexps
22845 The @code{gensub} function for more powerful text manipulation
22854 The ability for @code{FS} and for the third
22859 The ability for @code{RS} to be a regexp
22883 The @option{--traditional} option was added as a better name for
22900 The @code{BINMODE} special variable for non-POSIX systems,
22901 which allows binary I/O for input and/or output files
22909 The @code{PROCINFO} array for providing process-related information
22913 The @code{TEXTDOMAIN} special variable for setting an application's
22925 The @samp{|&} operator for two-way I/O to a coprocess
22929 The @file{/inet} special files for TCP/IP networking using @samp{|&}
22939 for capturing text-matching subexpressions within a regexp
22943 Positional specifiers in @code{printf} formats for
22948 The @code{asort} and @code{asorti} functions for sorting arrays
22953 for internationalization
22962 The @code{mktime} built-in function for creating timestamps
22980 The support for @samp{next file} as two words was removed completely
22988 The @option{--gen-po} command-line option and the use of a leading
22999 profiling version of @command{gawk}, for producing execution
23013 The use of GNU @code{gettext} for @command{gawk}'s own message output
23156 acts as coordinator for the various ports to different PC platforms
23157 and creates binary distributions for various PC operating systems.
23158 He is also instrumental in keeping the documentation up to date for
23165 built-in function for dynamically adding new modules.
23193 as well as the code for the new optional third argument to the @code{match} function.
23198 updated the @command{gawk} port for OS/2.
23202 of IBM in Japan, contributed support for multibyte characters.
23205 Michael Benzinger contributed the initial code for @code{switch} statements.
23208 Patrick T.J.@: McPhee contributed the code for dynamic loading in Windows32
23227 This appendix provides instructions for installing @command{gawk} on the
23232 for the electronic mail addresses of the people who did
23274 Software distributions are available for
23308 Once you have the distribution (for example,
23334 for getting and extracting the @command{gawk} distribution. You should consult
23357 Descriptive files: @file{README} for @command{gawk} under Unix and the
23358 rest for the various hardware and software combinations.
23373 A brief list of features and changes being contemplated for future
23374 releases, with some indication of the time frame for the feature, based
23383 A description of one area in which the POSIX standard for @command{awk} is
23389 A short article describing why @command{gawk} is a good language for
23400 The @command{troff} source for a five-color @command{awk} reference card.
23403 for instructions if you have an older @command{troff}.
23406 The @command{troff} source for a manual page describing @command{gawk}.
23407 This is distributed for the convenience of Unix users.
23411 The Texinfo source file for this @value{DOCUMENT}.
23416 The generated Info file for this @value{DOCUMENT}.
23419 The Texinfo source file for
23430 The generated Info file for
23434 The @command{troff} source for a manual page describing the @command{igawk}
23440 actual @file{Makefile} for creating the documentation.
23444 Files used by the GNU @command{automake} software for generating
23459 for various Unix systems. They are explained in
23463 @itemx po/*
23465 @command{gawk}'s internationalization features, while the @file{po} library
23475 source file for this @value{DOCUMENT}. It also contains a @file{Makefile.in} file, which
23488 Files needed for building @command{gawk} on an Atari ST
23489 (@pxref{Atari Installation}, for details).
23492 Files needed for building @command{gawk} on a Tandem
23493 (@pxref{Tandem Installation}, for details).
23496 Files needed for building @command{gawk} on POSIX-compliant systems.
23499 Files needed for building @command{gawk} under MS-DOS, MS Windows and OS/2
23500 (@pxref{PC Installation}, for details).
23503 Files needed for building @command{gawk} under VMS
23504 (@pxref{VMS Installation}, for details).
23507 A test suite for
23508 @command{gawk}. You can use @samp{make check} from the top-level @command{gawk}
23510 If @command{gawk} successfully passes @samp{make check}, then you can
23520 to configure @command{gawk} for your system yourself.
23529 @appendixsubsec Compiling @command{gawk} for Unix
23535 automatically for your Unix system by running the @command{configure} program.
23557 You might want to edit the @file{Makefile} to
23560 optimization levels or compiling for debugging).
23562 Alternatively, you can add your own values for most @command{make}
23571 See the file @file{INSTALL} in the @command{gawk} distribution for
23585 run @samp{make check}. All of the tests should succeed.
23587 check the files in the @file{README_d} directory to see if you've
23665 The source code for @command{gawk} generally attempts to adhere to formal
23687 It is possible for your C compiler to lie to @command{configure}. It may
23689 available. To get around this, edit the file @file{custom.h}.
23690 Use an @samp{#ifdef} that is appropriate for your system, and either
23698 If you do have a problem, the file @file{configure.in} is the input for
23702 for information on how to report problems in configuring @command{gawk}).
23732 A more complete distribution for the Amiga is available on
23770 prefix for the installation directory. For BeOS DR9 and beyond, the best directory to
23818 * PC Compiling:: Compiling @command{gawk} for MS-DOS, Windows32,
23820 * PC Dynamic:: Compiling @command{gawk} for dynamic libraries.
23823 * Cygwin:: Building and running @command{gawk} for
23828 @appendixsubsubsec Installing a Prepared Distribution for PC Systems
23834 This is designed for easy installation to a @file{/gnu} directory on your
23844 OS/2 (32 bit, EMX) binary distributions are prepared for the @file{/usr}
23866 @appendixsubsubsec Compiling @command{gawk} for PC Operating Systems
23868 @command{gawk} can be compiled for MS-DOS, Windows32, and OS/2 using the GNU
23872 used to build 16-bit versions for MS-DOS and OS/2.
23881 To build @command{gawk} for MS-DOS, Windows32, and OS/2 (16 bit only; for 32 bit
23883 for details see below), copy the files in the @file{pc} directory (@emph{except}
23884 for @file{ChangeLog}) to the directory with the rest of the @command{gawk}
23888 The @file{Makefile} contains a number of targets for building various MS-DOS,
23966 @samp{make check CMP="diff -a"} at your command prompt. All tests
23987 the @file{Makefile}. There are two definitions for @code{DYN_MAKEXP}:
23994 the @code{extension} function to match the name of the library (for
23996 @code{"ordchr"}), or rename the library to match the call (for instance,
24021 for your compiler.
24037 are not supported for MS-DOS or MS-Windows. EMX (OS/2 only) does support
24046 The OS/2 and MS-DOS versions of @command{gawk} search for program files as
24050 then the default search path for OS/2 (16 bit) and MS-DOS versions is
24053 The search path for OS/2 (32 bit, EMX) is determined by the prefix directory
24055 the @command{configure} script like it is the case for the Unix versions.
24058 Additionally, to support binary distributions of @command{gawk} for OS/2
24061 a drive then this specific drive is also searched for program files.
24066 or @command{cmd.exe} under OS/2) may be useful for @command{awk} programming.
24067 Ian Stewartson has written an excellent shell for MS-DOS and OS/2,
24069 and several shells are available for OS/2, including @command{ksh}. The file
24072 examine its documentation for handling command lines; in particular,
24073 the setting for @command{gawk} in the shell configuration may need to be
24096 binary mode is set for both read and write
24107 The modes for standard input and standard output are set one time
24110 Setting @code{BINMODE} for standard input or
24126 appropriate for files with the DOS-style end-of-line.
24128 To illustrate, the following examples set binary mode on writes for standard
24171 GNU Make, and other GNU tools. Compilation and installation for Cygwin
24172 is the same as for a Unix system:
24188 for any other environment for MS-DOS or MS-Windows.
24203 * VMS POSIX:: Alternate instructions for VMS POSIX.
24211 also a @file{Makefile} for use with the @code{MMS} utility. From the source
24231 @code{CC/OPTIMIZE=NOLINE}, which is essential for Version 3.0.
24237 Also edit @file{config.h} (which is a copy of file @file{[.config]vms-conf.h})
24243 from those for VAX C V2.x but equally straightforward. No changes to
24252 GNU C 1.40 and 2.3. It should work without modifications for VMS V4.6 and up.
24265 Substitute the actual location of @command{gawk.exe} for
24293 for @command{awk} program files. For the @option{-f} option, if the specified
24322 to the original shell-style interface (see the help entry for details).
24333 @cindex search paths, for source files
24334 The default search path, when looking for @command{awk} program files specified
24373 This sections describes systems for which
24385 included for those who might want to use it but it is no longer being
24401 These days this is the default and it may only be a problem for some
24403 flags, you need to upgrade your tools. Support for I/O
24423 optimization level for this particular file, which may help.
24438 Modify these sections as appropriate if they are not right for your
24457 using @command{gcc} libraries for TOS, @command{gawk} looks for either of
24459 If either one is found, its value is assumed to be a directory for
24463 current directory for its temporary files.
24465 The ST version of @command{gawk} searches for its program files, as described in
24467 The default value for the @env{AWKPATH} variable is taken from
24469 @file{Makefile} for the ST in the distribution sets @code{DEFPATH} to
24481 running under TOS. In some circumstances, the OS routines for file-handle
24496 It may also create problems for external programs called via the @code{system}
24513 The port is pretty clean and all facilities seem to work except for
24519 which is just too foreign a concept for Tandem.
24532 Usage is the same as for Unix, except that D20 requires all @samp{@{} and
24534 (but @emph{not} in script files). Also, the standard Tandem syntax for
24536 Unix @samp{<} and @samp{>} for file redirection. (Redirection options
24578 @cindex email address for bug reports, @code{bug-gawk@@gnu.org}
24596 above are the official recognized ways for reporting bugs.
24634 The Unix for OS/2 team, @email{gawk-maintainer@@unixos2.org}.
24661 @item OS/2 @tab The Unix for OS/2 team, @email{gawk-maintainer@@unixos2.org}.
24723 for a list of extensions in this @command{awk} that are not in POSIX @command{awk}.
24748 The @code{fflush} built-in function for flushing buffered output
24758 The use of @code{func} as an abbreviation for @code{function}
24772 The ability for @code{FS} and for the third
24781 The ability for @code{RS} to be a regexp
24785 The @code{BINMODE} special variable for non-Unix operating systems
24792 @cindex @command{awka} compiler for @command{awk}
24854 for a summary of the GNU extensions to the @command{awk} language and program.
24858 If @command{gawk} is compiled for debugging with @samp{-DDEBUG}, then there
24867 This option is intended only for serious @command{gawk} developers
24868 and not for the casual user. It probably has not even been compiled into
24901 make it possible for me to include your changes:
24912 It is much easier for me to integrate changes if they are relative to
24916 for information on getting the latest version of @command{gawk}.)
24932 An HTML version, suitable for reading with a WWW browser, is
24940 The C code for @command{gawk} follows the instructions in the
24943 of braces and the use of tabs. In brief, the coding rules for @command{gawk}
24959 (@code{if}, @code{while}, @code{for}, @code{do}, @code{switch},
24970 in @code{for} loop initialization and increment parts, and in macro bodies.
24973 Use real tabs for indenting, not spaces.
24980 @code{if}, @code{while}, and @code{for} statements, as well as in the @code{case}s
24991 traditional lowercase versions; these macros are better behaved for
24995 Provide one-line descriptive comments for each function.
25001 Do not use the @code{alloca} function for allocating memory off the stack.
25012 In order for the FSF to distribute your changes, you must either place
25024 for this @value{DOCUMENT}. If at all possible, please use real
25031 You will also have to sign paperwork for your documentation changes.
25042 (@xref{Bugs}, for the electronic mail
25045 Using this format makes it easy for me to apply your changes to the
25051 Include an entry for the @file{ChangeLog} file with your submission.
25053 making it easier for me to accept patches.
25058 isn't possible for me to do that with a minimum of extra work, then I
25088 avoid sprinkling @samp{#ifdef}s just for your port throughout the
25091 If the changes needed for a particular system affect too much of the
25100 unless it is for a very good reason; i.e., changes are not out of the
25123 or operating system for the port---for example, @file{pc/gawkmisc.pc} and
25127 @file{gawkmisc.c} file. (Currently, this is only an issue for the
25132 necessary for your operating system. All your code should be in a
25137 possible, then be sure to avoid using names for your files that
25142 Please write a section (or sections) for this @value{DOCUMENT} describing the
25144 @command{gawk} for your system.
25148 In order for the FSF to distribute your code, you must either place
25187 loaded extentions for @command{gawk}.
25206 The truth is that @command{gawk} was not designed for simple extensibility.
25207 The facilities for adding functions using shared libraries work, but
25269 be either @code{Node_var} or @code{Node_var_array} for function
25342 /* do_xxx --- do xxx function for gawk */
25396 /* check type */
25443 This @value{SECTION} implements these functions for @command{gawk} in an
25448 * Internal File Ops:: The code for internal file operations.
25484 @c broke printf for page breaking
25530 respectively. These are numeric timestamps, suitable for formatting
25537 @samp{ls -l}---for example, @code{"drwxr-xr-x"}.
25550 The file is a Solaris ``door'' (special file used for
25573 system and the type of the file. You can test for them in your @command{awk}
25579 The preferred block size for I/O to the file. This field is not
25595 @appendixsubsubsec C Code for @code{chdir} and @code{stat}
25597 Here is the C code for these extensions. They were written for
25598 GNU/Linux. The code needs some more work for complete portability
25600 slightly for presentation. The complete version can be found in
25603 @c break line for page breaking
25610 chdir() builtin for gawk */
25622 The file includes the @code{"awk.h"} header file for definitions
25623 for the @command{gawk} internals. It includes @code{<sys/sysmacros.h>}
25624 for access to the @code{major} and @code{minor} macros.
25627 By convention, for an @command{awk} function @code{foo}, the function that
25667 (e.g., 644 becomes @samp{-rw-r--r--}). This is omitted here for brevity:
25669 @c break line for page breaking
25686 Changed message for page breaking. Used to be:
25690 /* do_stat --- provide a stat() function for gawk */
25704 /* check arg count */
25716 @c comment made multiline for page breaking
25828 print "Info for testff.awk"
25831 for (i in data)
25842 @print{} Info for testff.awk
25897 : Before I actually release this for publication, I wanted to get your
25918 currently considering for @command{gawk}. The file @file{FUTURES} in the
25933 @item @code{RECLEN} variable for fixed-length records
25941 format specifiers. These should be evaluated for possible inclusion
25946 Add @samp{%'d} for putting in commas in formatting numeric values.
25957 There are more things that could be checked for portability.
26001 It should be possible for @command{gawk} to convert the script's parse tree
26008 An easier possibility might be for an intermediate phase of @command{gawk} to
26255 handles the mechanics of this for you.
26274 a task, or process data. It is much the same as a recipe for baking
26281 similar to the records a company keeps on employees, a school keeps for
26282 students, or a doctor keeps for patients.
26290 and even more often, as ``I/O'' for short.
26296 @command{awk} manages the reading of data for you, as well as the
26299 @dfn{patterns} in the data to look for, and @dfn{actions} to execute
26310 A variable is just a name for a given value, such as @code{first_name},
26366 and @command{gawk} provides functions for doing so.
26404 for C. This work culminated in 1989, with the production of the ANSI
26405 standard for C. This standard became an ISO standard in 1990.
26430 (double-precision floating-point) and the string value for a variable.
26436 It is important to note that the string value for a number may not
26444 # see it for what it is
26515 is that they often have more than one representation for the number zero!
26553 of lines long, including machine descriptions for several eight-bit
26574 many standards, among them the standards for the C and C++ programming
26586 Useful for reasoning about how a program is supposed to behave.
26608 Another name for an @command{awk} program.
26624 Short for ``Binary Digit.''
26652 @code{sqrt} (for the square root of a number) and @code{substr} (for a
26654 @command{gawk} provides functions for timestamp management, bit manipulation,
26697 for other users of the system, much like leaving paper notes on a bulletin
26719 Standard Code for Information Interchange). Many European
26724 A preprocessor for @command{pic} that reads descriptions of molecules
26725 and produces @command{pic} input for drawing them.
26762 and @code{for}
26768 @command{awk} for delimiting actions, compound statements, and function
26795 for the other to perform an action.
26820 The date used as the ``beginning of time'' for timestamps.
26822 with library functions available for converting these values into
26829 A special sequence of characters used for describing nonprinting
26830 characters, such as @samp{\n} for newline or @samp{\033} for the ASCII
26896 This is the old term for UTC.
26897 It is the time of day used as the epoch for Unix and POSIX systems.
26924 representing 10, @samp{B} representing 11, and so on, up to @samp{F} for 15.
26929 Abbreviation for ``Input/Output,'' the act of moving data into and/or
26960 This organization produces international standards for many things, including
26962 In the computer arena, important standards like those for C, C++, and POSIX
26977 @code{for},
26978 @code{for@dots{}in},
27004 The process of providing the data necessary for an
27008 An expression using the operators for logic, AND, OR, and NOT, written
27024 Characters used within a regexp that do not stand for themselves.
27058 The name for a series of standards
27061 the Unix heritage of these standards. The main standard of interest for
27063 @cite{IEEE Standard for Information Technology, Standard 1003.2-1992,
27072 Variables and/or functions that are meant for use exclusively by library
27073 functions and not for the main @command{awk} program. Special care must be
27079 can specify ranges of input lines for @command{awk} to process or it can
27084 If this isn't clear, refer to the entry for ``recursion.''
27098 Short for @dfn{regular expression}. A regexp is a pattern that denotes a
27117 @command{awk} reads an input record; then, for each rule, if the input record
27119 Otherwise, the rule does nothing for that input record.
27131 In @command{gawk}, a list of directories to search for @command{awk} program source files.
27132 In the shell, a list of directories to search for executable programs.
27135 The initial value, or starting point, for a sequence of random numbers.
27141 The command interpreter for Unix and POSIX-compliant systems.
27143 for batch files, or shell scripts.
27170 directly to the underlying operating system---for example, @file{/dev/stderr}.
27192 Used for grouping messages that are translated at runtime
27197 and POSIX systems. Used for the @command{gawk} functions
27217 The accepted abbreviation for ``Universal Coordinated Time.''
27219 reference time for day and date calculations.
27239 @c fakenode --- for prepinfo
27242 The licenses for most software are designed to take away your
27245 software---to make sure the software is free for all its users. This
27254 have the freedom to distribute copies of free software (and charge for
27261 These restrictions translate to certain responsibilities for you if you
27265 gratis or for a fee, you must give the recipients all the rights that
27274 Also, for each author's protection and ours, we want to make certain
27275 that everyone understands that there is no warranty for this free
27285 patent must be licensed for everyone's free use or not licensed at all.
27287 The precise terms and conditions for copying, distribution and
27291 @c fakenode --- for prepinfo
27292 @unnumberedsec Terms and Conditions for Copying, Distribution and Modification
27326 You may charge a fee for the physical act of transferring a copy, and
27327 you may at your option offer warranty protection in exchange for a fee.
27348 when run, you must cause it, when started running for such
27366 this License, whose permissions for other licensees extend to the
27388 1 and 2 above on a medium customarily used for software interchange; or,
27391 Accompany it with a written offer, valid for at least three
27392 years, to give any third party, for a charge no more than your
27396 customarily used for software interchange; or,
27401 allowed only for noncommercial distribution and only if you
27406 The source code for a work means the preferred form of the work for
27408 code means all the source code for all modules it contains, plus any
27439 all its terms and conditions for copying, distributing or modifying
27448 You are not responsible for enforcing compliance by third parties to
27453 infringement or for any other reason (not limited to patent issues),
27510 to ask for permission. For software which is copyrighted by the Free
27512 make exceptions for this. Our decision will be guided by the two goals
27517 @c fakenode --- for prepinfo
27548 @c fakenode --- for prepinfo
27556 @c fakenode --- for prepinfo
27580 GNU General Public License for more details.
27594 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
27597 for details.
27607 school, if any, to sign a ``copyright disclaimer'' for the program, if
27652 Secondarily, this License preserves for the author and publisher a way
27653 to get credit for their work, while not being considered responsible
27654 for modifications made by others.
27659 license designed for free software.
27661 We have designed this License in order to use it for manuals for free
27665 it can be used for any textual work, regardless of subject matter or
27667 principally for works whose purpose is instruction or reference.
27712 general public, that is suitable for revising the document
27713 straightforwardly with generic text editors or (for images composed of
27714 pixels) generic paint programs or (for drawings) some widely available
27715 drawing editor, and that is suitable for input to text formatters or
27716 for automatic translation to a variety of formats suitable for input
27720 An image format is not Transparent if used for any substantial amount
27723 Examples of suitable formats for Transparent copies include plain
27727 PostScript or @acronym{PDF} designed for human modification. Examples
27731 @acronym{XML} for which the @acronym{DTD} and/or processing tools are
27733 PostScript or @acronym{PDF} produced by some word processors for
27736 The ``Title Page'' means, for a printed book, the title page itself,
27745 text that translates XYZ in another language. (Here XYZ stands for a
27768 compensation in exchange for copies. If you distribute a large enough
27790 If the required texts for either cover are too voluminous to fit
27832 responsible for authorship of the modifications in the Modified
27845 Add an appropriate copyright notice for your modifications
27870 Preserve the network location, if any, given in the Document for
27872 the network locations given in the Document for previous versions
27874 You may omit a network location for a work that was published at
27910 parties---for example, statements of peer review or that the text has
27919 includes a cover text for the same cover, previously added by you or
27925 give permission to use their names for publicity for or to assert or
27932 License, under the terms defined in section 4 above for modified
27959 the collection, provided that you follow the rules of this License for
28012 as expressly provided for under this License. Any other attempt to
28038 @c fakenode --- for prepinfo
28039 @unnumberedsec ADDENDUM: How to use this License for your documents
28108 The term "blank" is thus basically reserved for "blank lines" etc.
28136 The words "a", "and", "as", "between", "for", "from", "in", "of",
28140 Search for @dfn; make sure important items are also indexed.
28170 Use @code{xxx} for the xxx operator in indexing statements, not @samp.
28177 It's a GNU convention to use the term "file name" for the name of a
28178 file, never "pathname". We use the term "path" for search paths,
28179 which are lists of file names. Using it for a single file name as
28182 So please check any documentation you maintain, if you think you might
28200 % 2. Use @code{foo} for variables and @code{foo()} for functions