diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-06-09 20:13:44 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-06-09 20:13:44 +0300 |
commit | e0cb2b1f1b87cfc493db276c85bbec8246cd4b3b (patch) | |
tree | fde7343678445a6ac2a25af6a79c65859176eb09 | |
parent | 4bf0a8ccb72ea56ae4e7f576dd1902603b521e8d (diff) | |
download | egawk-e0cb2b1f1b87cfc493db276c85bbec8246cd4b3b.tar.gz egawk-e0cb2b1f1b87cfc493db276c85bbec8246cd4b3b.tar.bz2 egawk-e0cb2b1f1b87cfc493db276c85bbec8246cd4b3b.zip |
More summary sections.
-rw-r--r-- | doc/ChangeLog | 4 | ||||
-rw-r--r-- | doc/gawk.info | 1142 | ||||
-rw-r--r-- | doc/gawk.texi | 237 | ||||
-rw-r--r-- | doc/gawktexi.in | 237 |
4 files changed, 1151 insertions, 469 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index 0ad1a947..c0a5f853 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2014-06-09 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in: More "Summary" sections. + 2014-06-08 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Start adding "Summary" sections. diff --git a/doc/gawk.info b/doc/gawk.info index 50ccda25..9d472b67 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -4042,6 +4042,7 @@ have to be named on the `awk' command line (*note Getline::). * Read Timeout:: Reading input with a timeout. * Command line directories:: What happens if you put a directory on the command line. +* Input Summary:: Input summary. File: gawk.info, Node: Records, Next: Fields, Up: Reading Files @@ -5829,7 +5830,7 @@ writing. (1) This assumes that standard input is the keyboard. -File: gawk.info, Node: Command line directories, Prev: Read Timeout, Up: Reading Files +File: gawk.info, Node: Command line directories, Next: Input Summary, Prev: Read Timeout, Up: Reading Files 4.11 Directories On The Command Line ==================================== @@ -5852,6 +5853,75 @@ error. usable data from an `awk' program. +File: gawk.info, Node: Input Summary, Prev: Command line directories, Up: Reading Files + +4.12 Summary +============ + + * Input is split into records based on the value of `RS'. The + possibilities are as follows: + + Value of `RS' Records are split on `awk' / `gawk' + ---------------------------------------------------------------------- + Any single That character `awk' + character + The empty string Runs of two or more `awk' + (`""') newlines + A regexp Text that matches the `gawk' + regexp + + * `gawk' sets `RT' to the text matched by `RS'. + + * After splitting the input into records, `awk' further splits the + record into individual fields, named `$1', `$2' and so on. `$0' is + the whole record, and `NF' indicates how many fields there are. + The default way to split fields is between whitespace characters. + + * Fields may be referenced using a variable, as in `$NF'. Fields + may also be assigned values, which causes the value of `$0' to be + recomputed when it is later referenced. Assigning to a field with + a number greater than `NF' creates the field and rebuilds the + record, using `OFS' to separate the fields. Incrementing `NF' + does the same thing. Decrementing `NF' throws away fields and + rebuilds the record. + + * Field splitting is more complicated than record splitting. + + Field separator value Fields are split ... `awk' / + `gawk' + ---------------------------------------------------------------------- + `FS == " "' On runs of whitespace `awk' + `FS == ANY SINGLE On that character `awk' + CHARACTER' + `FS == REGEXP' On text matching the `awk' + regexp + `FS == ""' Each individual character `gawk' + is a separate field + `FIELDWIDTHS == LIST OF Based on character `gawk' + COLUMNS' position + `FPAT == REGEXP' On text around text `gawk' + matching the regexp + + Using `FS = "\n"' causes the entire record to be a single field + (assuming that newlines separate records). + + * `FS' may be set from the command line using the `-F' option. This + can also be done using command-line variable assignment. + + * `PROCINFO["FS"]' can be used to see how fields are being split. + + * Use `getline' in its varioius forms to read additional records, + from the default input stream, from a file, or from a pipe or + co-process. + + * Use `PROCINFO[FILE, "READ_TIMEOUT"]' to cause reads to timeout for + FILE. + + * Directories on the command line are fatal for standard `awk'; + `gawk' ignores them if not in POSIX mode. + + + File: gawk.info, Node: Printing, Next: Expressions, Prev: Reading Files, Up: Top 5 Printing Output @@ -5885,6 +5955,7 @@ function. `gawk' allows access to inherited file descriptors. * Close Files And Pipes:: Closing Input and Output Files and Pipes. +* Output Summary:: Output summary. File: gawk.info, Node: Print, Next: Print Examples, Up: Printing @@ -6776,7 +6847,7 @@ that `gawk' provides: behavior. -File: gawk.info, Node: Close Files And Pipes, Prev: Special Files, Up: Printing +File: gawk.info, Node: Close Files And Pipes, Next: Output Summary, Prev: Special Files, Up: Printing 5.8 Closing Input and Output Redirections ========================================= @@ -6943,6 +7014,32 @@ call. See the system manual pages for information on how to decode this value. +File: gawk.info, Node: Output Summary, Prev: Close Files And Pipes, Up: Printing + +5.9 Summary +=========== + + * The `print' statement prints comma-separated expressions. Each + expression is separated by the value of `OFS' and terminated by + the value of `ORS'. `OFMT' provides the conversion format for + numeric values for the `print' statement. + + * The `printf' statement provides finer-grained control over output, + with format control letters for different data types and various + flags that modify the behavior of the format control letters. + + * Output from both `print' and `printf' may be redirected to files, + pipes, and co-processes. + + * `gawk' provides special file names for access to standard input, + output and error, and for network communications. + + * Use `close()' to close open file, pipe and co-process redirections. + For co-processes, it is possible to close only one direction of the + communications. + + + File: gawk.info, Node: Expressions, Next: Patterns and Actions, Prev: Printing, Up: Top 6 Expressions @@ -6968,6 +7065,7 @@ operators. * Function Calls:: A function call is an expression. * Precedence:: How various operators nest. * Locales:: How the locale affects things. +* Expressions Summary:: Expressions summary. File: gawk.info, Node: Values, Next: All Operators, Up: Expressions @@ -8516,7 +8614,7 @@ String Concatenation POSIX. For maximum portability, do not use them. -File: gawk.info, Node: Locales, Prev: Precedence, Up: Expressions +File: gawk.info, Node: Locales, Next: Expressions Summary, Prev: Precedence, Up: Expressions 6.6 Where You Are Makes A Difference ==================================== @@ -8552,6 +8650,62 @@ used when `gawk' parses input data. This is discussed in detail in *note Conversion::. +File: gawk.info, Node: Expressions Summary, Prev: Locales, Up: Expressions + +6.7 Summary +=========== + + * Expressions are the basic elements of computation in programs. + They are built from constants, variables, function calls and + combinations of the various kinds of values with operators. + + * `awk' supplies three kinds of constants: numeric, string, and + regexp. `gawk' lets you specify numeric constants in octal and + hexadecimal (bases 8 and 16) in addition to decimal (base 10). In + certain contexts, a standalone regexp constant such as `/foo/' has + the same meaning as `$0 ~ /foo/'. + + * Variables hold values between uses in computations. A number of + built-in variables provide information to your `awk' program, and + a number of others let you control how `awk' behaves. + + * Numbers are automatically converted to strings, and strings to + numbers, as needed by `awk'. Numeric values are converted as if + they were formatted with `sprintf()' using the format in `CONVFMT'. + + * `awk' provides the usual arithmetic operators (addition, + subtraction, multiplication, division, modulus), and unary plus + and minus. It also provides comparison operators, boolean + operators, and regexp matching operators. String concatenation is + accomplished by placing two expressions next to each other; there + is no explicit operator. The three-operand `?:' operator provides + an "if-else" test within expressions. + + * Assignment operators provide convenient shorthands for common + arithmetic operations. + + * In `awk', a value is considered to be true if it is non-zero _or_ + non-null. Otherwise, the value is false. + + * A value's type is set upon each assignment and may change over its + lifetime. The type determines how it behaves in comparisons + (string or numeric). + + * Function calls return a value which may be used as part of a larger + expression. Expressions used to pass parameter values are fully + evaluated before the function is called. `awk' provides built-in + and user-defined functions; this is described later on in this + Info file. + + * Operator precedence specifies the order in which operations are + performed, unless explicitly overridden by parentheses. `awk''s + operator precedence is compatible with that of C. + + * Locales can affect the format of data as output by an `awk' + program, and occasionally the format for data read as input. + + + File: gawk.info, Node: Patterns and Actions, Next: Arrays, Prev: Expressions, Up: Top 7 Patterns, Actions, and Variables @@ -8575,6 +8729,7 @@ top of. Now it's time to start building something useful. * Statements:: Describes the various control statements in detail. * Built-in Variables:: Summarizes the built-in variables. +* Pattern Action Summary:: Patterns and Actions summary. File: gawk.info, Node: Pattern Overview, Next: Using Shell Variables, Up: Patterns and Actions @@ -9667,7 +9822,7 @@ statement with a nonzero argument, as shown in the following example: systems. -File: gawk.info, Node: Built-in Variables, Prev: Statements, Up: Patterns and Actions +File: gawk.info, Node: Built-in Variables, Next: Pattern Action Summary, Prev: Statements, Up: Patterns and Actions 7.5 Built-in Variables ====================== @@ -10285,6 +10440,55 @@ are passed on to the `awk' program. (*Note Getopt Function::, for an `awk' library function that parses command-line options.) +File: gawk.info, Node: Pattern Action Summary, Prev: Built-in Variables, Up: Patterns and Actions + +7.6 Summary +=========== + + * Pattern-action pairs make up the basic elements of an `awk' + program. Patterns are either normal expressions, range + expressions, regexp constants, one of the special keywords + `BEGIN', `END', `BEGINFILE', `ENDFILE', or empty. The action + executes if the current record matches the pattern. Empty + (missing) patterns match all records. + + * I/O from `BEGIN' and `END' rules have certain constraints. This + is also true, only more so, for `BEGINFILE' and `ENDFILE' rules. + The latter two give you "hooks" into `gawk''s file processing, + allowing you to recover from a file that otherwise would cause a + fatal error (such as a file that cannot be opened). + + * Shell variables can be used in `awk' programs by careful use of + shell quoting. It is easier to pass a shell variable into `awk' + by using the `-v' option and an `awk' variable. + + * Actions consist of statements enclosed in curly braces. Statements + are built up from expressions, control statements, compound + statements, input and output statements, and deletion statements. + + * The control statements in `awk' are `if'-`else', `while', `for', + and `do'-`while'. `gawk' adds the `switch' statement. There are + two flavors of `for' statement: one for for performing general + looping, and the other iterating through an array. + + * `break' and `continue' let you exit early or start the next + iteration of a loop (or get out of a `switch'). + + * `next' and `nextfile' let you read the next record and start over + at the top of your program, or skip to the next input file and + start over, respectively. + + * The `exit' statement terminates your program. When executed from + an action (or function body) it transfers control to the `END' + statements. From an `END' statement body, it exits immediately. + You may pass an optional numeric value to be used at `awk''s exit + status. + + * Some built-in variables provide control over `awk', mainly for I/O. + Other variables convey information from `awk' to your program. + + + File: gawk.info, Node: Arrays, Next: Functions, Prev: Patterns and Actions, Up: Top 8 Arrays in `awk' @@ -33403,468 +33607,472 @@ Node: Leftmost Longest176154 Node: Computed Regexps177355 Node: Regexp Summary180727 Node: Reading Files182199 -Node: Records184201 -Node: awk split records184944 -Node: gawk split records189802 -Ref: gawk split records-Footnote-1194323 -Node: Fields194360 -Ref: Fields-Footnote-1197324 -Node: Nonconstant Fields197410 -Ref: Nonconstant Fields-Footnote-1199640 -Node: Changing Fields199842 -Node: Field Separators205796 -Node: Default Field Splitting208498 -Node: Regexp Field Splitting209615 -Node: Single Character Fields212956 -Node: Command Line Field Separator214015 -Node: Full Line Fields217357 -Ref: Full Line Fields-Footnote-1217865 -Node: Field Splitting Summary217911 -Ref: Field Splitting Summary-Footnote-1221010 -Node: Constant Size221111 -Node: Splitting By Content225718 -Ref: Splitting By Content-Footnote-1229468 -Node: Multiple Line229508 -Ref: Multiple Line-Footnote-1235364 -Node: Getline235543 -Node: Plain Getline237759 -Node: Getline/Variable239854 -Node: Getline/File241001 -Node: Getline/Variable/File242377 -Ref: Getline/Variable/File-Footnote-1243976 -Node: Getline/Pipe244063 -Node: Getline/Variable/Pipe246762 -Node: Getline/Coprocess247869 -Node: Getline/Variable/Coprocess249121 -Node: Getline Notes249858 -Node: Getline Summary252662 -Ref: table-getline-variants253070 -Node: Read Timeout253982 -Ref: Read Timeout-Footnote-1257809 -Node: Command line directories257867 -Node: Printing258749 -Node: Print260373 -Node: Print Examples261714 -Node: Output Separators264493 -Node: OFMT266509 -Node: Printf267867 -Node: Basic Printf268773 -Node: Control Letters270312 -Node: Format Modifiers274166 -Node: Printf Examples280193 -Node: Redirection282900 -Node: Special Files289847 -Node: Special FD290363 -Ref: Special FD-Footnote-1293938 -Node: Special Network294012 -Node: Special Caveats294848 -Node: Close Files And Pipes295623 -Ref: Close Files And Pipes-Footnote-1302739 -Ref: Close Files And Pipes-Footnote-2302887 -Node: Expressions303037 -Node: Values304169 -Node: Constants304845 -Node: Scalar Constants305525 -Ref: Scalar Constants-Footnote-1306384 -Node: Nondecimal-numbers306634 -Node: Regexp Constants309634 -Node: Using Constant Regexps310109 -Node: Variables313179 -Node: Using Variables313834 -Node: Assignment Options315558 -Node: Conversion317425 -Ref: table-locale-affects322861 -Ref: Conversion-Footnote-1323485 -Node: All Operators323594 -Node: Arithmetic Ops324224 -Node: Concatenation326729 -Ref: Concatenation-Footnote-1329525 -Node: Assignment Ops329645 -Ref: table-assign-ops334628 -Node: Increment Ops335945 -Node: Truth Values and Conditions339383 -Node: Truth Values340466 -Node: Typing and Comparison341515 -Node: Variable Typing342308 -Ref: Variable Typing-Footnote-1346208 -Node: Comparison Operators346330 -Ref: table-relational-ops346740 -Node: POSIX String Comparison350290 -Ref: POSIX String Comparison-Footnote-1351374 -Node: Boolean Ops351512 -Ref: Boolean Ops-Footnote-1355582 -Node: Conditional Exp355673 -Node: Function Calls357400 -Node: Precedence361158 -Node: Locales364827 -Node: Patterns and Actions366430 -Node: Pattern Overview367484 -Node: Regexp Patterns369161 -Node: Expression Patterns369704 -Node: Ranges373485 -Node: BEGIN/END376591 -Node: Using BEGIN/END377353 -Ref: Using BEGIN/END-Footnote-1380089 -Node: I/O And BEGIN/END380195 -Node: BEGINFILE/ENDFILE382480 -Node: Empty385411 -Node: Using Shell Variables385728 -Node: Action Overview388011 -Node: Statements390338 -Node: If Statement392186 -Node: While Statement393684 -Node: Do Statement395728 -Node: For Statement396884 -Node: Switch Statement400036 -Node: Break Statement402139 -Node: Continue Statement404194 -Node: Next Statement405987 -Node: Nextfile Statement408377 -Node: Exit Statement411032 -Node: Built-in Variables413436 -Node: User-modified414532 -Ref: User-modified-Footnote-1422217 -Node: Auto-set422279 -Ref: Auto-set-Footnote-1434825 -Ref: Auto-set-Footnote-2435030 -Node: ARGC and ARGV435086 -Node: Arrays438925 -Node: Array Basics440423 -Node: Array Intro441249 -Ref: figure-array-elements443222 -Node: Reference to Elements445629 -Node: Assigning Elements447902 -Node: Array Example448393 -Node: Scanning an Array450125 -Node: Controlling Scanning453140 -Ref: Controlling Scanning-Footnote-1458313 -Node: Delete458629 -Ref: Delete-Footnote-1461394 -Node: Numeric Array Subscripts461451 -Node: Uninitialized Subscripts463634 -Node: Multidimensional465259 -Node: Multiscanning468352 -Node: Arrays of Arrays469941 -Node: Functions474581 -Node: Built-in475400 -Node: Calling Built-in476478 -Node: Numeric Functions478466 -Ref: Numeric Functions-Footnote-1482300 -Ref: Numeric Functions-Footnote-2482657 -Ref: Numeric Functions-Footnote-3482705 -Node: String Functions482974 -Ref: String Functions-Footnote-1505985 -Ref: String Functions-Footnote-2506114 -Ref: String Functions-Footnote-3506362 -Node: Gory Details506449 -Ref: table-sub-escapes508118 -Ref: table-sub-posix-92509472 -Ref: table-sub-proposed510823 -Ref: table-posix-sub512177 -Ref: table-gensub-escapes513722 -Ref: Gory Details-Footnote-1514898 -Ref: Gory Details-Footnote-2514949 -Node: I/O Functions515100 -Ref: I/O Functions-Footnote-1522223 -Node: Time Functions522370 -Ref: Time Functions-Footnote-1532834 -Ref: Time Functions-Footnote-2532902 -Ref: Time Functions-Footnote-3533060 -Ref: Time Functions-Footnote-4533171 -Ref: Time Functions-Footnote-5533283 -Ref: Time Functions-Footnote-6533510 -Node: Bitwise Functions533776 -Ref: table-bitwise-ops534338 -Ref: Bitwise Functions-Footnote-1538583 -Node: Type Functions538767 -Node: I18N Functions539909 -Node: User-defined541554 -Node: Definition Syntax542358 -Ref: Definition Syntax-Footnote-1547283 -Node: Function Example547352 -Ref: Function Example-Footnote-1549996 -Node: Function Caveats550018 -Node: Calling A Function550536 -Node: Variable Scope551491 -Node: Pass By Value/Reference554479 -Node: Return Statement557987 -Node: Dynamic Typing560971 -Node: Indirect Calls561900 -Node: Library Functions571587 -Ref: Library Functions-Footnote-1575100 -Ref: Library Functions-Footnote-2575243 -Node: Library Names575414 -Ref: Library Names-Footnote-1578887 -Ref: Library Names-Footnote-2579107 -Node: General Functions579193 -Node: Strtonum Function580221 -Node: Assert Function583151 -Node: Round Function586477 -Node: Cliff Random Function588018 -Node: Ordinal Functions589034 -Ref: Ordinal Functions-Footnote-1592111 -Ref: Ordinal Functions-Footnote-2592363 -Node: Join Function592574 -Ref: Join Function-Footnote-1594345 -Node: Getlocaltime Function594545 -Node: Readfile Function598281 -Node: Data File Management600120 -Node: Filetrans Function600752 -Node: Rewind Function604807 -Node: File Checking606194 -Ref: File Checking-Footnote-1607326 -Node: Empty Files607527 -Node: Ignoring Assigns609750 -Node: Getopt Function611281 -Ref: Getopt Function-Footnote-1622577 -Node: Passwd Functions622780 -Ref: Passwd Functions-Footnote-1631759 -Node: Group Functions631847 -Ref: Group Functions-Footnote-1639789 -Node: Walking Arrays640002 -Node: Sample Programs642138 -Node: Running Examples642812 -Node: Clones643540 -Node: Cut Program644764 -Node: Egrep Program654625 -Ref: Egrep Program-Footnote-1662554 -Node: Id Program662664 -Node: Split Program666328 -Ref: Split Program-Footnote-1669859 -Node: Tee Program669987 -Node: Uniq Program672794 -Node: Wc Program680224 -Ref: Wc Program-Footnote-1684492 -Ref: Wc Program-Footnote-2684692 -Node: Miscellaneous Programs684784 -Node: Dupword Program685972 -Node: Alarm Program688003 -Node: Translate Program692817 -Ref: Translate Program-Footnote-1697208 -Ref: Translate Program-Footnote-2697478 -Node: Labels Program697612 -Ref: Labels Program-Footnote-1700983 -Node: Word Sorting701067 -Node: History Sorting705110 -Node: Extract Program706946 -Ref: Extract Program-Footnote-1714521 -Node: Simple Sed714650 -Node: Igawk Program717712 -Ref: Igawk Program-Footnote-1732888 -Ref: Igawk Program-Footnote-2733089 -Node: Anagram Program733227 -Node: Signature Program736295 -Node: Advanced Features737542 -Node: Nondecimal Data739428 -Node: Array Sorting741005 -Node: Controlling Array Traversal741702 -Node: Array Sorting Functions749982 -Ref: Array Sorting Functions-Footnote-1753889 -Node: Two-way I/O754083 -Ref: Two-way I/O-Footnote-1759599 -Node: TCP/IP Networking759681 -Node: Profiling762525 -Node: Internationalization770033 -Node: I18N and L10N771458 -Node: Explaining gettext772144 -Ref: Explaining gettext-Footnote-1777284 -Ref: Explaining gettext-Footnote-2777468 -Node: Programmer i18n777633 -Node: Translator i18n781858 -Node: String Extraction782652 -Ref: String Extraction-Footnote-1783613 -Node: Printf Ordering783699 -Ref: Printf Ordering-Footnote-1786481 -Node: I18N Portability786545 -Ref: I18N Portability-Footnote-1788994 -Node: I18N Example789057 -Ref: I18N Example-Footnote-1791779 -Node: Gawk I18N791851 -Node: Debugger792464 -Node: Debugging793435 -Node: Debugging Concepts793876 -Node: Debugging Terms795732 -Node: Awk Debugging798329 -Node: Sample Debugging Session799221 -Node: Debugger Invocation799741 -Node: Finding The Bug801074 -Node: List of Debugger Commands807556 -Node: Breakpoint Control808888 -Node: Debugger Execution Control812552 -Node: Viewing And Changing Data815912 -Node: Execution Stack819270 -Node: Debugger Info820783 -Node: Miscellaneous Debugger Commands824777 -Node: Readline Support829961 -Node: Limitations830853 -Node: Arbitrary Precision Arithmetic833101 -Ref: Arbitrary Precision Arithmetic-Footnote-1834750 -Node: General Arithmetic834898 -Node: Floating Point Issues836618 -Node: String Conversion Precision837499 -Ref: String Conversion Precision-Footnote-1839204 -Node: Unexpected Results839313 -Node: POSIX Floating Point Problems841466 -Ref: POSIX Floating Point Problems-Footnote-1845287 -Node: Integer Programming845325 -Node: Floating-point Programming847136 -Ref: Floating-point Programming-Footnote-1853464 -Ref: Floating-point Programming-Footnote-2853734 -Node: Floating-point Representation853998 -Node: Floating-point Context855163 -Ref: table-ieee-formats856002 -Node: Rounding Mode857386 -Ref: table-rounding-modes857865 -Ref: Rounding Mode-Footnote-1860880 -Node: Gawk and MPFR861059 -Node: Arbitrary Precision Floats862468 -Ref: Arbitrary Precision Floats-Footnote-1864911 -Node: Setting Precision865232 -Ref: table-predefined-precision-strings865916 -Node: Setting Rounding Mode868061 -Ref: table-gawk-rounding-modes868465 -Node: Floating-point Constants869652 -Node: Changing Precision871104 -Ref: Changing Precision-Footnote-1872496 -Node: Exact Arithmetic872670 -Node: Arbitrary Precision Integers875804 -Ref: Arbitrary Precision Integers-Footnote-1878819 -Node: Dynamic Extensions878966 -Node: Extension Intro880424 -Node: Plugin License881689 -Node: Extension Mechanism Outline882374 -Ref: figure-load-extension882798 -Ref: figure-load-new-function884283 -Ref: figure-call-new-function885285 -Node: Extension API Description887269 -Node: Extension API Functions Introduction888719 -Node: General Data Types893585 -Ref: General Data Types-Footnote-1899278 -Node: Requesting Values899577 -Ref: table-value-types-returned900314 -Node: Memory Allocation Functions901272 -Ref: Memory Allocation Functions-Footnote-1904019 -Node: Constructor Functions904115 -Node: Registration Functions905873 -Node: Extension Functions906558 -Node: Exit Callback Functions908860 -Node: Extension Version String910110 -Node: Input Parsers910760 -Node: Output Wrappers920563 -Node: Two-way processors925079 -Node: Printing Messages927283 -Ref: Printing Messages-Footnote-1928360 -Node: Updating `ERRNO'928512 -Node: Accessing Parameters929251 -Node: Symbol Table Access930481 -Node: Symbol table by name930995 -Node: Symbol table by cookie932971 -Ref: Symbol table by cookie-Footnote-1937104 -Node: Cached values937167 -Ref: Cached values-Footnote-1940672 -Node: Array Manipulation940763 -Ref: Array Manipulation-Footnote-1941861 -Node: Array Data Types941900 -Ref: Array Data Types-Footnote-1944603 -Node: Array Functions944695 -Node: Flattening Arrays948569 -Node: Creating Arrays955421 -Node: Extension API Variables960152 -Node: Extension Versioning960788 -Node: Extension API Informational Variables962689 -Node: Extension API Boilerplate963775 -Node: Finding Extensions967579 -Node: Extension Example968139 -Node: Internal File Description968869 -Node: Internal File Ops972960 -Ref: Internal File Ops-Footnote-1984506 -Node: Using Internal File Ops984646 -Ref: Using Internal File Ops-Footnote-1986993 -Node: Extension Samples987261 -Node: Extension Sample File Functions988785 -Node: Extension Sample Fnmatch996353 -Node: Extension Sample Fork997820 -Node: Extension Sample Inplace999033 -Node: Extension Sample Ord1000799 -Node: Extension Sample Readdir1001635 -Ref: table-readdir-file-types1002484 -Node: Extension Sample Revout1003283 -Node: Extension Sample Rev2way1003874 -Node: Extension Sample Read write array1004615 -Node: Extension Sample Readfile1006494 -Node: Extension Sample API Tests1007594 -Node: Extension Sample Time1008119 -Node: gawkextlib1009434 -Node: Language History1012221 -Node: V7/SVR3.11013815 -Node: SVR41016135 -Node: POSIX1017577 -Node: BTL1018963 -Node: POSIX/GNU1019697 -Node: Feature History1025296 -Node: Common Extensions1038408 -Node: Ranges and Locales1039720 -Ref: Ranges and Locales-Footnote-11044337 -Ref: Ranges and Locales-Footnote-21044364 -Ref: Ranges and Locales-Footnote-31044598 -Node: Contributors1044819 -Node: Installation1050257 -Node: Gawk Distribution1051151 -Node: Getting1051635 -Node: Extracting1052461 -Node: Distribution contents1054103 -Node: Unix Installation1059820 -Node: Quick Installation1060437 -Node: Additional Configuration Options1062879 -Node: Configuration Philosophy1064617 -Node: Non-Unix Installation1066968 -Node: PC Installation1067426 -Node: PC Binary Installation1068737 -Node: PC Compiling1070585 -Ref: PC Compiling-Footnote-11073584 -Node: PC Testing1073689 -Node: PC Using1074865 -Node: Cygwin1079023 -Node: MSYS1079832 -Node: VMS Installation1080346 -Node: VMS Compilation1081142 -Ref: VMS Compilation-Footnote-11082357 -Node: VMS Dynamic Extensions1082415 -Node: VMS Installation Details1083788 -Node: VMS Running1086034 -Node: VMS GNV1088868 -Node: VMS Old Gawk1089591 -Node: Bugs1090061 -Node: Other Versions1094065 -Node: Notes1100290 -Node: Compatibility Mode1101090 -Node: Additions1101872 -Node: Accessing The Source1102797 -Node: Adding Code1104233 -Node: New Ports1110411 -Node: Derived Files1114892 -Ref: Derived Files-Footnote-11119973 -Ref: Derived Files-Footnote-21120007 -Ref: Derived Files-Footnote-31120603 -Node: Future Extensions1120717 -Node: Implementation Limitations1121323 -Node: Extension Design1122571 -Node: Old Extension Problems1123725 -Ref: Old Extension Problems-Footnote-11125242 -Node: Extension New Mechanism Goals1125299 -Ref: Extension New Mechanism Goals-Footnote-11128660 -Node: Extension Other Design Decisions1128849 -Node: Extension Future Growth1130955 -Node: Old Extension Mechanism1131791 -Node: Basic Concepts1133531 -Node: Basic High Level1134212 -Ref: figure-general-flow1134484 -Ref: figure-process-flow1135083 -Ref: Basic High Level-Footnote-11138312 -Node: Basic Data Typing1138497 -Node: Glossary1141824 -Node: Copying1166976 -Node: GNU Free Documentation License1204532 -Node: Index1229668 +Node: Records184248 +Node: awk split records184991 +Node: gawk split records189849 +Ref: gawk split records-Footnote-1194370 +Node: Fields194407 +Ref: Fields-Footnote-1197371 +Node: Nonconstant Fields197457 +Ref: Nonconstant Fields-Footnote-1199687 +Node: Changing Fields199889 +Node: Field Separators205843 +Node: Default Field Splitting208545 +Node: Regexp Field Splitting209662 +Node: Single Character Fields213003 +Node: Command Line Field Separator214062 +Node: Full Line Fields217404 +Ref: Full Line Fields-Footnote-1217912 +Node: Field Splitting Summary217958 +Ref: Field Splitting Summary-Footnote-1221057 +Node: Constant Size221158 +Node: Splitting By Content225765 +Ref: Splitting By Content-Footnote-1229515 +Node: Multiple Line229555 +Ref: Multiple Line-Footnote-1235411 +Node: Getline235590 +Node: Plain Getline237806 +Node: Getline/Variable239901 +Node: Getline/File241048 +Node: Getline/Variable/File242424 +Ref: Getline/Variable/File-Footnote-1244023 +Node: Getline/Pipe244110 +Node: Getline/Variable/Pipe246809 +Node: Getline/Coprocess247916 +Node: Getline/Variable/Coprocess249168 +Node: Getline Notes249905 +Node: Getline Summary252709 +Ref: table-getline-variants253117 +Node: Read Timeout254029 +Ref: Read Timeout-Footnote-1257856 +Node: Command line directories257914 +Node: Input Summary258818 +Node: Printing261932 +Node: Print263604 +Node: Print Examples264945 +Node: Output Separators267724 +Node: OFMT269740 +Node: Printf271098 +Node: Basic Printf272004 +Node: Control Letters273543 +Node: Format Modifiers277397 +Node: Printf Examples283424 +Node: Redirection286131 +Node: Special Files293078 +Node: Special FD293594 +Ref: Special FD-Footnote-1297169 +Node: Special Network297243 +Node: Special Caveats298079 +Node: Close Files And Pipes298854 +Ref: Close Files And Pipes-Footnote-1305993 +Ref: Close Files And Pipes-Footnote-2306141 +Node: Output Summary306291 +Node: Expressions307263 +Node: Values308448 +Node: Constants309124 +Node: Scalar Constants309804 +Ref: Scalar Constants-Footnote-1310663 +Node: Nondecimal-numbers310913 +Node: Regexp Constants313913 +Node: Using Constant Regexps314388 +Node: Variables317458 +Node: Using Variables318113 +Node: Assignment Options319837 +Node: Conversion321704 +Ref: table-locale-affects327140 +Ref: Conversion-Footnote-1327764 +Node: All Operators327873 +Node: Arithmetic Ops328503 +Node: Concatenation331008 +Ref: Concatenation-Footnote-1333804 +Node: Assignment Ops333924 +Ref: table-assign-ops338907 +Node: Increment Ops340224 +Node: Truth Values and Conditions343662 +Node: Truth Values344745 +Node: Typing and Comparison345794 +Node: Variable Typing346587 +Ref: Variable Typing-Footnote-1350487 +Node: Comparison Operators350609 +Ref: table-relational-ops351019 +Node: POSIX String Comparison354569 +Ref: POSIX String Comparison-Footnote-1355653 +Node: Boolean Ops355791 +Ref: Boolean Ops-Footnote-1359861 +Node: Conditional Exp359952 +Node: Function Calls361679 +Node: Precedence365437 +Node: Locales369106 +Node: Expressions Summary370737 +Node: Patterns and Actions373234 +Node: Pattern Overview374350 +Node: Regexp Patterns376027 +Node: Expression Patterns376570 +Node: Ranges380351 +Node: BEGIN/END383457 +Node: Using BEGIN/END384219 +Ref: Using BEGIN/END-Footnote-1386955 +Node: I/O And BEGIN/END387061 +Node: BEGINFILE/ENDFILE389346 +Node: Empty392277 +Node: Using Shell Variables392594 +Node: Action Overview394877 +Node: Statements397204 +Node: If Statement399052 +Node: While Statement400550 +Node: Do Statement402594 +Node: For Statement403750 +Node: Switch Statement406902 +Node: Break Statement409005 +Node: Continue Statement411060 +Node: Next Statement412853 +Node: Nextfile Statement415243 +Node: Exit Statement417898 +Node: Built-in Variables420302 +Node: User-modified421429 +Ref: User-modified-Footnote-1429114 +Node: Auto-set429176 +Ref: Auto-set-Footnote-1441722 +Ref: Auto-set-Footnote-2441927 +Node: ARGC and ARGV441983 +Node: Pattern Action Summary445822 +Node: Arrays448045 +Node: Array Basics449543 +Node: Array Intro450369 +Ref: figure-array-elements452342 +Node: Reference to Elements454749 +Node: Assigning Elements457022 +Node: Array Example457513 +Node: Scanning an Array459245 +Node: Controlling Scanning462260 +Ref: Controlling Scanning-Footnote-1467433 +Node: Delete467749 +Ref: Delete-Footnote-1470514 +Node: Numeric Array Subscripts470571 +Node: Uninitialized Subscripts472754 +Node: Multidimensional474379 +Node: Multiscanning477472 +Node: Arrays of Arrays479061 +Node: Functions483701 +Node: Built-in484520 +Node: Calling Built-in485598 +Node: Numeric Functions487586 +Ref: Numeric Functions-Footnote-1491420 +Ref: Numeric Functions-Footnote-2491777 +Ref: Numeric Functions-Footnote-3491825 +Node: String Functions492094 +Ref: String Functions-Footnote-1515105 +Ref: String Functions-Footnote-2515234 +Ref: String Functions-Footnote-3515482 +Node: Gory Details515569 +Ref: table-sub-escapes517238 +Ref: table-sub-posix-92518592 +Ref: table-sub-proposed519943 +Ref: table-posix-sub521297 +Ref: table-gensub-escapes522842 +Ref: Gory Details-Footnote-1524018 +Ref: Gory Details-Footnote-2524069 +Node: I/O Functions524220 +Ref: I/O Functions-Footnote-1531343 +Node: Time Functions531490 +Ref: Time Functions-Footnote-1541954 +Ref: Time Functions-Footnote-2542022 +Ref: Time Functions-Footnote-3542180 +Ref: Time Functions-Footnote-4542291 +Ref: Time Functions-Footnote-5542403 +Ref: Time Functions-Footnote-6542630 +Node: Bitwise Functions542896 +Ref: table-bitwise-ops543458 +Ref: Bitwise Functions-Footnote-1547703 +Node: Type Functions547887 +Node: I18N Functions549029 +Node: User-defined550674 +Node: Definition Syntax551478 +Ref: Definition Syntax-Footnote-1556403 +Node: Function Example556472 +Ref: Function Example-Footnote-1559116 +Node: Function Caveats559138 +Node: Calling A Function559656 +Node: Variable Scope560611 +Node: Pass By Value/Reference563599 +Node: Return Statement567107 +Node: Dynamic Typing570091 +Node: Indirect Calls571020 +Node: Library Functions580707 +Ref: Library Functions-Footnote-1584220 +Ref: Library Functions-Footnote-2584363 +Node: Library Names584534 +Ref: Library Names-Footnote-1588007 +Ref: Library Names-Footnote-2588227 +Node: General Functions588313 +Node: Strtonum Function589341 +Node: Assert Function592271 +Node: Round Function595597 +Node: Cliff Random Function597138 +Node: Ordinal Functions598154 +Ref: Ordinal Functions-Footnote-1601231 +Ref: Ordinal Functions-Footnote-2601483 +Node: Join Function601694 +Ref: Join Function-Footnote-1603465 +Node: Getlocaltime Function603665 +Node: Readfile Function607401 +Node: Data File Management609240 +Node: Filetrans Function609872 +Node: Rewind Function613927 +Node: File Checking615314 +Ref: File Checking-Footnote-1616446 +Node: Empty Files616647 +Node: Ignoring Assigns618870 +Node: Getopt Function620401 +Ref: Getopt Function-Footnote-1631697 +Node: Passwd Functions631900 +Ref: Passwd Functions-Footnote-1640879 +Node: Group Functions640967 +Ref: Group Functions-Footnote-1648909 +Node: Walking Arrays649122 +Node: Sample Programs651258 +Node: Running Examples651932 +Node: Clones652660 +Node: Cut Program653884 +Node: Egrep Program663745 +Ref: Egrep Program-Footnote-1671674 +Node: Id Program671784 +Node: Split Program675448 +Ref: Split Program-Footnote-1678979 +Node: Tee Program679107 +Node: Uniq Program681914 +Node: Wc Program689344 +Ref: Wc Program-Footnote-1693612 +Ref: Wc Program-Footnote-2693812 +Node: Miscellaneous Programs693904 +Node: Dupword Program695092 +Node: Alarm Program697123 +Node: Translate Program701937 +Ref: Translate Program-Footnote-1706328 +Ref: Translate Program-Footnote-2706598 +Node: Labels Program706732 +Ref: Labels Program-Footnote-1710103 +Node: Word Sorting710187 +Node: History Sorting714230 +Node: Extract Program716066 +Ref: Extract Program-Footnote-1723641 +Node: Simple Sed723770 +Node: Igawk Program726832 +Ref: Igawk Program-Footnote-1742008 +Ref: Igawk Program-Footnote-2742209 +Node: Anagram Program742347 +Node: Signature Program745415 +Node: Advanced Features746662 +Node: Nondecimal Data748548 +Node: Array Sorting750125 +Node: Controlling Array Traversal750822 +Node: Array Sorting Functions759102 +Ref: Array Sorting Functions-Footnote-1763009 +Node: Two-way I/O763203 +Ref: Two-way I/O-Footnote-1768719 +Node: TCP/IP Networking768801 +Node: Profiling771645 +Node: Internationalization779153 +Node: I18N and L10N780578 +Node: Explaining gettext781264 +Ref: Explaining gettext-Footnote-1786404 +Ref: Explaining gettext-Footnote-2786588 +Node: Programmer i18n786753 +Node: Translator i18n790978 +Node: String Extraction791772 +Ref: String Extraction-Footnote-1792733 +Node: Printf Ordering792819 +Ref: Printf Ordering-Footnote-1795601 +Node: I18N Portability795665 +Ref: I18N Portability-Footnote-1798114 +Node: I18N Example798177 +Ref: I18N Example-Footnote-1800899 +Node: Gawk I18N800971 +Node: Debugger801584 +Node: Debugging802555 +Node: Debugging Concepts802996 +Node: Debugging Terms804852 +Node: Awk Debugging807449 +Node: Sample Debugging Session808341 +Node: Debugger Invocation808861 +Node: Finding The Bug810194 +Node: List of Debugger Commands816676 +Node: Breakpoint Control818008 +Node: Debugger Execution Control821672 +Node: Viewing And Changing Data825032 +Node: Execution Stack828390 +Node: Debugger Info829903 +Node: Miscellaneous Debugger Commands833897 +Node: Readline Support839081 +Node: Limitations839973 +Node: Arbitrary Precision Arithmetic842221 +Ref: Arbitrary Precision Arithmetic-Footnote-1843870 +Node: General Arithmetic844018 +Node: Floating Point Issues845738 +Node: String Conversion Precision846619 +Ref: String Conversion Precision-Footnote-1848324 +Node: Unexpected Results848433 +Node: POSIX Floating Point Problems850586 +Ref: POSIX Floating Point Problems-Footnote-1854407 +Node: Integer Programming854445 +Node: Floating-point Programming856256 +Ref: Floating-point Programming-Footnote-1862584 +Ref: Floating-point Programming-Footnote-2862854 +Node: Floating-point Representation863118 +Node: Floating-point Context864283 +Ref: table-ieee-formats865122 +Node: Rounding Mode866506 +Ref: table-rounding-modes866985 +Ref: Rounding Mode-Footnote-1870000 +Node: Gawk and MPFR870179 +Node: Arbitrary Precision Floats871588 +Ref: Arbitrary Precision Floats-Footnote-1874031 +Node: Setting Precision874352 +Ref: table-predefined-precision-strings875036 +Node: Setting Rounding Mode877181 +Ref: table-gawk-rounding-modes877585 +Node: Floating-point Constants878772 +Node: Changing Precision880224 +Ref: Changing Precision-Footnote-1881616 +Node: Exact Arithmetic881790 +Node: Arbitrary Precision Integers884924 +Ref: Arbitrary Precision Integers-Footnote-1887939 +Node: Dynamic Extensions888086 +Node: Extension Intro889544 +Node: Plugin License890809 +Node: Extension Mechanism Outline891494 +Ref: figure-load-extension891918 +Ref: figure-load-new-function893403 +Ref: figure-call-new-function894405 +Node: Extension API Description896389 +Node: Extension API Functions Introduction897839 +Node: General Data Types902705 +Ref: General Data Types-Footnote-1908398 +Node: Requesting Values908697 +Ref: table-value-types-returned909434 +Node: Memory Allocation Functions910392 +Ref: Memory Allocation Functions-Footnote-1913139 +Node: Constructor Functions913235 +Node: Registration Functions914993 +Node: Extension Functions915678 +Node: Exit Callback Functions917980 +Node: Extension Version String919230 +Node: Input Parsers919880 +Node: Output Wrappers929683 +Node: Two-way processors934199 +Node: Printing Messages936403 +Ref: Printing Messages-Footnote-1937480 +Node: Updating `ERRNO'937632 +Node: Accessing Parameters938371 +Node: Symbol Table Access939601 +Node: Symbol table by name940115 +Node: Symbol table by cookie942091 +Ref: Symbol table by cookie-Footnote-1946224 +Node: Cached values946287 +Ref: Cached values-Footnote-1949792 +Node: Array Manipulation949883 +Ref: Array Manipulation-Footnote-1950981 +Node: Array Data Types951020 +Ref: Array Data Types-Footnote-1953723 +Node: Array Functions953815 +Node: Flattening Arrays957689 +Node: Creating Arrays964541 +Node: Extension API Variables969272 +Node: Extension Versioning969908 +Node: Extension API Informational Variables971809 +Node: Extension API Boilerplate972895 +Node: Finding Extensions976699 +Node: Extension Example977259 +Node: Internal File Description977989 +Node: Internal File Ops982080 +Ref: Internal File Ops-Footnote-1993626 +Node: Using Internal File Ops993766 +Ref: Using Internal File Ops-Footnote-1996113 +Node: Extension Samples996381 +Node: Extension Sample File Functions997905 +Node: Extension Sample Fnmatch1005473 +Node: Extension Sample Fork1006940 +Node: Extension Sample Inplace1008153 +Node: Extension Sample Ord1009919 +Node: Extension Sample Readdir1010755 +Ref: table-readdir-file-types1011604 +Node: Extension Sample Revout1012403 +Node: Extension Sample Rev2way1012994 +Node: Extension Sample Read write array1013735 +Node: Extension Sample Readfile1015614 +Node: Extension Sample API Tests1016714 +Node: Extension Sample Time1017239 +Node: gawkextlib1018554 +Node: Language History1021341 +Node: V7/SVR3.11022935 +Node: SVR41025255 +Node: POSIX1026697 +Node: BTL1028083 +Node: POSIX/GNU1028817 +Node: Feature History1034416 +Node: Common Extensions1047528 +Node: Ranges and Locales1048840 +Ref: Ranges and Locales-Footnote-11053457 +Ref: Ranges and Locales-Footnote-21053484 +Ref: Ranges and Locales-Footnote-31053718 +Node: Contributors1053939 +Node: Installation1059377 +Node: Gawk Distribution1060271 +Node: Getting1060755 +Node: Extracting1061581 +Node: Distribution contents1063223 +Node: Unix Installation1068940 +Node: Quick Installation1069557 +Node: Additional Configuration Options1071999 +Node: Configuration Philosophy1073737 +Node: Non-Unix Installation1076088 +Node: PC Installation1076546 +Node: PC Binary Installation1077857 +Node: PC Compiling1079705 +Ref: PC Compiling-Footnote-11082704 +Node: PC Testing1082809 +Node: PC Using1083985 +Node: Cygwin1088143 +Node: MSYS1088952 +Node: VMS Installation1089466 +Node: VMS Compilation1090262 +Ref: VMS Compilation-Footnote-11091477 +Node: VMS Dynamic Extensions1091535 +Node: VMS Installation Details1092908 +Node: VMS Running1095154 +Node: VMS GNV1097988 +Node: VMS Old Gawk1098711 +Node: Bugs1099181 +Node: Other Versions1103185 +Node: Notes1109410 +Node: Compatibility Mode1110210 +Node: Additions1110992 +Node: Accessing The Source1111917 +Node: Adding Code1113353 +Node: New Ports1119531 +Node: Derived Files1124012 +Ref: Derived Files-Footnote-11129093 +Ref: Derived Files-Footnote-21129127 +Ref: Derived Files-Footnote-31129723 +Node: Future Extensions1129837 +Node: Implementation Limitations1130443 +Node: Extension Design1131691 +Node: Old Extension Problems1132845 +Ref: Old Extension Problems-Footnote-11134362 +Node: Extension New Mechanism Goals1134419 +Ref: Extension New Mechanism Goals-Footnote-11137780 +Node: Extension Other Design Decisions1137969 +Node: Extension Future Growth1140075 +Node: Old Extension Mechanism1140911 +Node: Basic Concepts1142651 +Node: Basic High Level1143332 +Ref: figure-general-flow1143604 +Ref: figure-process-flow1144203 +Ref: Basic High Level-Footnote-11147432 +Node: Basic Data Typing1147617 +Node: Glossary1150944 +Node: Copying1176096 +Node: GNU Free Documentation License1213652 +Node: Index1238788 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 7f85c13c..97d4ced9 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -1460,9 +1460,15 @@ Primarily, this @value{DOCUMENT} explains the features of @command{awk} as defined in the POSIX standard. It does so in the context of the @command{gawk} implementation. While doing so, it also attempts to describe important differences between @command{gawk} -and other @command{awk} implementations.@footnote{All such differences +and other @command{awk} +@ifclear FOR_PRINT +implementations.@footnote{All such differences appear in the index under the entry ``differences in @command{awk} and @command{gawk}.''} +@end ifclear +@ifset FOR_PRINT +implementations. +@end ifset Finally, any @command{gawk} features that are not in the POSIX standard for @command{awk} are noted. @@ -6027,6 +6033,7 @@ used with it do not have to be named on the @command{awk} command line * Read Timeout:: Reading input with a timeout. * Command line directories:: What happens if you put a directory on the command line. +* Input Summary:: Input summary. @end menu @node Records @@ -8505,6 +8512,75 @@ to treating a directory on the command line as a fatal error. @xref{Extension Sample Readdir}, for a way to treat directories as usable data from an @command{awk} program. +@node Input Summary +@section Summary + +@itemize @value{BULLET} +@item +Input is split into records based on the value of @code{RS}. +The possibilities are as follows: + +@multitable @columnfractions .25 .35 .40 +@headitem Value of @code{RS} @tab Records are split on @tab @command{awk} / @command{gawk} +@item Any single character @tab That character @tab @command{awk} +@item The empty string (@code{""}) @tab Runs of two or more newlines @tab @command{awk} +@item A regexp @tab Text that matches the regexp @tab @command{gawk} +@end multitable + +@item +@command{gawk} sets @code{RT} to the text matched by @code{RS}. + +@item +After splitting the input into records, @command{awk} further splits the record +into individual fields, named @code{$1}, @code{$2} and so on. @code{$0} is the +whole record, and @code{NF} indicates how many fields there are. The default way +to split fields is between whitespace characters. + +@item +Fields may be referenced using a variable, as in @samp{$NF}. Fields may also be +assigned values, which causes the value of @code{$0} to be recomputed when it is +later referenced. Assigning to a field with a number greater than @code{NF} +creates the field and rebuilds the record, using @code{OFS} to separate the fields. +Incrementing @code{NF} does the same thing. Decrementing @code{NF} throws away fields +and rebuilds the record. + +@item +Field splitting is more complicated than record splitting. + +@multitable @columnfractions .40 .40 .20 +@headitem Field separator value @tab Fields are split @dots{} @tab @command{awk} / @command{gawk} +@item @code{FS == " "} @tab On runs of whitespace @tab @command{awk} +@item @code{FS == @var{any single character}} @tab On that character @tab @command{awk} +@item @code{FS == @var{regexp}} @tab On text matching the regexp @tab @command{awk} +@item @code{FS == ""} @tab Each individual character is a separate field @tab @command{gawk} +@item @code{FIELDWIDTHS == @var{list of columns}} @tab Based on character position @tab @command{gawk} +@item @code{FPAT == @var{regexp}} @tab On text around text matching the regexp @tab @command{gawk} +@end multitable + +Using @samp{FS = "\n"} causes the entire record to be a single field (assuming +that newlines separate records). + +@item +@code{FS} may be set from the command line using the @option{-F} option. +This can also be done using command-line variable assignment. + +@item +@code{PROCINFO["FS"]} can be used to see how fields are being split. + +@item +Use @code{getline} in its varioius forms to read additional records, +from the default input stream, from a file, or from a pipe or co-process. + +@item +Use @code{PROCINFO[@var{file}, "READ_TIMEOUT"]} to cause reads to timeout +for @var{file}. + +@item +Directories on the command line are fatal for standard @command{awk}; +@command{gawk} ignores them if not in POSIX mode. + +@end itemize + @node Printing @chapter Printing Output @@ -8544,6 +8620,7 @@ and discusses the @code{close()} built-in function. @command{gawk} allows access to inherited file descriptors. * Close Files And Pipes:: Closing Input and Output Files and Pipes. +* Output Summary:: Output summary. @end menu @node Print @@ -10033,6 +10110,38 @@ when closing a pipe. @c ENDOFRANGE ofc @c ENDOFRANGE pc @c ENDOFRANGE cc + +@node Output Summary +@section Summary + +@itemize @value{BULLET} +@item +The @code{print} statement prints comma-separated expressions. Each expression +is separated by the value of @code{OFS} and terminated by the value of @code{ORS}. +@code{OFMT} provides the conversion format for numeric values for the @code{print} +statement. + +@item +The @code{printf} statement provides finer-grained control over output, with format +control letters for different data types and various flags that modify the +behavior of the format control letters. + +@item +Output from both @code{print} and @code{printf} may be redirected to files, +pipes, and co-processes. + +@item +@command{gawk} provides special file names for access to standard input, output +and error, and for network communications. + +@item +Use @code{close()} to close open file, pipe and co-process redirections. +For co-processes, it is possible to close only one direction of the +communications. + +@end itemize + + @c ENDOFRANGE prnt @node Expressions @@ -10059,6 +10168,7 @@ combinations of these with various operators. * Function Calls:: A function call is an expression. * Precedence:: How various operators nest. * Locales:: How the locale affects things. +* Expressions Summary:: Expressions summary. @end menu @node Values @@ -12454,6 +12564,71 @@ Finally, the locale affects the value of the decimal point character used when @command{gawk} parses input data. This is discussed in detail in @ref{Conversion}. +@node Expressions Summary +@section Summary + +@itemize @value{BULLET} +@item +Expressions are the basic elements of computation in programs. +They are built from constants, variables, function calls and combinations +of the various kinds of values with operators. + +@item +@command{awk} supplies three kinds of constants: numeric, string, and +regexp. @command{gawk} lets you specify numeric constants in octal +and hexadecimal (bases 8 and 16) in addition to decimal (base 10). +In certain contexts, a standalone regexp constant such as @code{/foo/} +has the same meaning as @samp{$0 ~ /foo/}. + +@item +Variables hold values between uses in computations. A number of built-in +variables provide information to your @command{awk} program, and a number +of others let you control how @command{awk} behaves. + +@item +Numbers are automatically converted to strings, and strings to numbers, +as needed by @command{awk}. Numeric values are converted as if they were +formatted with @code{sprintf()} using the format in @code{CONVFMT}. + +@item +@command{awk} provides the usual arithmetic operators (addition, +subtraction, multiplication, division, modulus), and unary plus and minus. +It also provides comparison operators, boolean operators, and regexp +matching operators. String concatenation is accomplished by placing +two expressions next to each other; there is no explicit operator. +The three-operand @samp{?:} operator provides an ``if-else'' test +within expressions. + +@item +Assignment operators provide convenient shorthands for common arithmetic +operations. + +@item +In @command{awk}, a value is considered to be true if it is non-zero +@emph{or} non-null. Otherwise, the value is false. + +@item +A value's type is set upon each assignment and may change over its lifetime. +The type determines how it behaves in comparisons (string or numeric). + +@item +Function calls return a value which may be used as part of a larger +expression. Expressions used to pass parameter values are fully +evaluated before the function is called. @command{awk} provides +built-in and user-defined functions; this is described later on in +this @value{DOCUMENT}. + +@item +Operator precedence specifies the order in which operations are +performed, unless explicitly overridden by parentheses. @command{awk}'s +operator precedence is compatible with that of C. + +@item +Locales can affect the format of data as output by an @command{awk} +program, and occasionally the format for data read as input. + +@end itemize + @c ENDOFRANGE exps @node Patterns and Actions @@ -12480,6 +12655,7 @@ building something useful. * Statements:: Describes the various control statements in detail. * Built-in Variables:: Summarizes the built-in variables. +* Pattern Action Summary:: Patterns and Actions summary. @end menu @node Pattern Overview @@ -14749,6 +14925,65 @@ are passed on to the @command{awk} program. (@xref{Getopt Function}, for an @command{awk} library function that parses command-line options.) +@node Pattern Action Summary +@section Summary + +@itemize @value{BULLET} +@item +Pattern-action pairs make up the basic elements of an @command{awk} +program. Patterns are either normal expressions, range expressions, +regexp constants, one of the special keywords @code{BEGIN}, @code{END}, +@code{BEGINFILE}, @code{ENDFILE}, or empty. The action executes if +the current record matches the pattern. Empty (missing) patterns match +all records. + +@item +I/O from @code{BEGIN} and @code{END} rules have certain constraints. +This is also true, only more so, for @code{BEGINFILE} and @code{ENDFILE} +rules. The latter two give you ``hooks'' into @command{gawk}'s file +processing, allowing you to recover from a file that otherwise would +cause a fatal error (such as a file that cannot be opened). + +@item +Shell variables can be used in @command{awk} programs by careful +use of shell quoting. It is easier to pass a shell variable into +@command{awk} by using the @option{-v} option and an @command{awk} +variable. + +@item +Actions consist of statements enclosed in curly braces. Statements +are built up from expressions, control statements, compound statements, +input and output statements, and deletion statements. + +@item +The control statements in @command{awk} are @code{if}-@code{else}, +@code{while}, @code{for}, and @code{do}-@code{while}. @command{gawk} +adds the @code{switch} statement. There are two flavors of @code{for} +statement: one for for performing general looping, and the other iterating +through an array. + +@item +@code{break} and @code{continue} let you exit early or start the next +iteration of a loop (or get out of a @code{switch}). + +@item +@code{next} and @code{nextfile} let you read the next record and start +over at the top of your program, or skip to the next input file and +start over, respectively. + +@item +The @code{exit} statement terminates your program. When executed +from an action (or function body) it transfers control to the +@code{END} statements. From an @code{END} statement body, it exits +immediately. You may pass an optional numeric value to be used +at @command{awk}'s exit status. + +@item +Some built-in variables provide control over @command{awk}, mainly for I/O. +Other variables convey information from @command{awk} to your program. + +@end itemize + @node Arrays @chapter Arrays in @command{awk} @c STARTOFRANGE arrs diff --git a/doc/gawktexi.in b/doc/gawktexi.in index e64382e6..899f1e03 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -1427,9 +1427,15 @@ Primarily, this @value{DOCUMENT} explains the features of @command{awk} as defined in the POSIX standard. It does so in the context of the @command{gawk} implementation. While doing so, it also attempts to describe important differences between @command{gawk} -and other @command{awk} implementations.@footnote{All such differences +and other @command{awk} +@ifclear FOR_PRINT +implementations.@footnote{All such differences appear in the index under the entry ``differences in @command{awk} and @command{gawk}.''} +@end ifclear +@ifset FOR_PRINT +implementations. +@end ifset Finally, any @command{gawk} features that are not in the POSIX standard for @command{awk} are noted. @@ -5828,6 +5834,7 @@ used with it do not have to be named on the @command{awk} command line * Read Timeout:: Reading input with a timeout. * Command line directories:: What happens if you put a directory on the command line. +* Input Summary:: Input summary. @end menu @node Records @@ -8124,6 +8131,75 @@ to treating a directory on the command line as a fatal error. @xref{Extension Sample Readdir}, for a way to treat directories as usable data from an @command{awk} program. +@node Input Summary +@section Summary + +@itemize @value{BULLET} +@item +Input is split into records based on the value of @code{RS}. +The possibilities are as follows: + +@multitable @columnfractions .25 .35 .40 +@headitem Value of @code{RS} @tab Records are split on @tab @command{awk} / @command{gawk} +@item Any single character @tab That character @tab @command{awk} +@item The empty string (@code{""}) @tab Runs of two or more newlines @tab @command{awk} +@item A regexp @tab Text that matches the regexp @tab @command{gawk} +@end multitable + +@item +@command{gawk} sets @code{RT} to the text matched by @code{RS}. + +@item +After splitting the input into records, @command{awk} further splits the record +into individual fields, named @code{$1}, @code{$2} and so on. @code{$0} is the +whole record, and @code{NF} indicates how many fields there are. The default way +to split fields is between whitespace characters. + +@item +Fields may be referenced using a variable, as in @samp{$NF}. Fields may also be +assigned values, which causes the value of @code{$0} to be recomputed when it is +later referenced. Assigning to a field with a number greater than @code{NF} +creates the field and rebuilds the record, using @code{OFS} to separate the fields. +Incrementing @code{NF} does the same thing. Decrementing @code{NF} throws away fields +and rebuilds the record. + +@item +Field splitting is more complicated than record splitting. + +@multitable @columnfractions .40 .40 .20 +@headitem Field separator value @tab Fields are split @dots{} @tab @command{awk} / @command{gawk} +@item @code{FS == " "} @tab On runs of whitespace @tab @command{awk} +@item @code{FS == @var{any single character}} @tab On that character @tab @command{awk} +@item @code{FS == @var{regexp}} @tab On text matching the regexp @tab @command{awk} +@item @code{FS == ""} @tab Each individual character is a separate field @tab @command{gawk} +@item @code{FIELDWIDTHS == @var{list of columns}} @tab Based on character position @tab @command{gawk} +@item @code{FPAT == @var{regexp}} @tab On text around text matching the regexp @tab @command{gawk} +@end multitable + +Using @samp{FS = "\n"} causes the entire record to be a single field (assuming +that newlines separate records). + +@item +@code{FS} may be set from the command line using the @option{-F} option. +This can also be done using command-line variable assignment. + +@item +@code{PROCINFO["FS"]} can be used to see how fields are being split. + +@item +Use @code{getline} in its varioius forms to read additional records, +from the default input stream, from a file, or from a pipe or co-process. + +@item +Use @code{PROCINFO[@var{file}, "READ_TIMEOUT"]} to cause reads to timeout +for @var{file}. + +@item +Directories on the command line are fatal for standard @command{awk}; +@command{gawk} ignores them if not in POSIX mode. + +@end itemize + @node Printing @chapter Printing Output @@ -8163,6 +8239,7 @@ and discusses the @code{close()} built-in function. @command{gawk} allows access to inherited file descriptors. * Close Files And Pipes:: Closing Input and Output Files and Pipes. +* Output Summary:: Output summary. @end menu @node Print @@ -9552,6 +9629,38 @@ when closing a pipe. @c ENDOFRANGE ofc @c ENDOFRANGE pc @c ENDOFRANGE cc + +@node Output Summary +@section Summary + +@itemize @value{BULLET} +@item +The @code{print} statement prints comma-separated expressions. Each expression +is separated by the value of @code{OFS} and terminated by the value of @code{ORS}. +@code{OFMT} provides the conversion format for numeric values for the @code{print} +statement. + +@item +The @code{printf} statement provides finer-grained control over output, with format +control letters for different data types and various flags that modify the +behavior of the format control letters. + +@item +Output from both @code{print} and @code{printf} may be redirected to files, +pipes, and co-processes. + +@item +@command{gawk} provides special file names for access to standard input, output +and error, and for network communications. + +@item +Use @code{close()} to close open file, pipe and co-process redirections. +For co-processes, it is possible to close only one direction of the +communications. + +@end itemize + + @c ENDOFRANGE prnt @node Expressions @@ -9578,6 +9687,7 @@ combinations of these with various operators. * Function Calls:: A function call is an expression. * Precedence:: How various operators nest. * Locales:: How the locale affects things. +* Expressions Summary:: Expressions summary. @end menu @node Values @@ -11834,6 +11944,71 @@ Finally, the locale affects the value of the decimal point character used when @command{gawk} parses input data. This is discussed in detail in @ref{Conversion}. +@node Expressions Summary +@section Summary + +@itemize @value{BULLET} +@item +Expressions are the basic elements of computation in programs. +They are built from constants, variables, function calls and combinations +of the various kinds of values with operators. + +@item +@command{awk} supplies three kinds of constants: numeric, string, and +regexp. @command{gawk} lets you specify numeric constants in octal +and hexadecimal (bases 8 and 16) in addition to decimal (base 10). +In certain contexts, a standalone regexp constant such as @code{/foo/} +has the same meaning as @samp{$0 ~ /foo/}. + +@item +Variables hold values between uses in computations. A number of built-in +variables provide information to your @command{awk} program, and a number +of others let you control how @command{awk} behaves. + +@item +Numbers are automatically converted to strings, and strings to numbers, +as needed by @command{awk}. Numeric values are converted as if they were +formatted with @code{sprintf()} using the format in @code{CONVFMT}. + +@item +@command{awk} provides the usual arithmetic operators (addition, +subtraction, multiplication, division, modulus), and unary plus and minus. +It also provides comparison operators, boolean operators, and regexp +matching operators. String concatenation is accomplished by placing +two expressions next to each other; there is no explicit operator. +The three-operand @samp{?:} operator provides an ``if-else'' test +within expressions. + +@item +Assignment operators provide convenient shorthands for common arithmetic +operations. + +@item +In @command{awk}, a value is considered to be true if it is non-zero +@emph{or} non-null. Otherwise, the value is false. + +@item +A value's type is set upon each assignment and may change over its lifetime. +The type determines how it behaves in comparisons (string or numeric). + +@item +Function calls return a value which may be used as part of a larger +expression. Expressions used to pass parameter values are fully +evaluated before the function is called. @command{awk} provides +built-in and user-defined functions; this is described later on in +this @value{DOCUMENT}. + +@item +Operator precedence specifies the order in which operations are +performed, unless explicitly overridden by parentheses. @command{awk}'s +operator precedence is compatible with that of C. + +@item +Locales can affect the format of data as output by an @command{awk} +program, and occasionally the format for data read as input. + +@end itemize + @c ENDOFRANGE exps @node Patterns and Actions @@ -11860,6 +12035,7 @@ building something useful. * Statements:: Describes the various control statements in detail. * Built-in Variables:: Summarizes the built-in variables. +* Pattern Action Summary:: Patterns and Actions summary. @end menu @node Pattern Overview @@ -14083,6 +14259,65 @@ are passed on to the @command{awk} program. (@xref{Getopt Function}, for an @command{awk} library function that parses command-line options.) +@node Pattern Action Summary +@section Summary + +@itemize @value{BULLET} +@item +Pattern-action pairs make up the basic elements of an @command{awk} +program. Patterns are either normal expressions, range expressions, +regexp constants, one of the special keywords @code{BEGIN}, @code{END}, +@code{BEGINFILE}, @code{ENDFILE}, or empty. The action executes if +the current record matches the pattern. Empty (missing) patterns match +all records. + +@item +I/O from @code{BEGIN} and @code{END} rules have certain constraints. +This is also true, only more so, for @code{BEGINFILE} and @code{ENDFILE} +rules. The latter two give you ``hooks'' into @command{gawk}'s file +processing, allowing you to recover from a file that otherwise would +cause a fatal error (such as a file that cannot be opened). + +@item +Shell variables can be used in @command{awk} programs by careful +use of shell quoting. It is easier to pass a shell variable into +@command{awk} by using the @option{-v} option and an @command{awk} +variable. + +@item +Actions consist of statements enclosed in curly braces. Statements +are built up from expressions, control statements, compound statements, +input and output statements, and deletion statements. + +@item +The control statements in @command{awk} are @code{if}-@code{else}, +@code{while}, @code{for}, and @code{do}-@code{while}. @command{gawk} +adds the @code{switch} statement. There are two flavors of @code{for} +statement: one for for performing general looping, and the other iterating +through an array. + +@item +@code{break} and @code{continue} let you exit early or start the next +iteration of a loop (or get out of a @code{switch}). + +@item +@code{next} and @code{nextfile} let you read the next record and start +over at the top of your program, or skip to the next input file and +start over, respectively. + +@item +The @code{exit} statement terminates your program. When executed +from an action (or function body) it transfers control to the +@code{END} statements. From an @code{END} statement body, it exits +immediately. You may pass an optional numeric value to be used +at @command{awk}'s exit status. + +@item +Some built-in variables provide control over @command{awk}, mainly for I/O. +Other variables convey information from @command{awk} to your program. + +@end itemize + @node Arrays @chapter Arrays in @command{awk} @c STARTOFRANGE arrs |