home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 6 / FreshFish_September1994.bin / bbs / gnu / gawk-2.15.5-src.lha / GNU / src / amiga / gawk-2.15.5 / gawk.info-7 < prev    next >
Encoding:
GNU Info File  |  1994-06-13  |  49.3 KB  |  1,266 lines

  1. This is Info file gawk.info, produced by Makeinfo-1.55 from the input
  2. file /gnu/src/amiga/gawk-2.15.5/gawk.texi.
  3.  
  4.    This file documents `awk', a program that you can use to select
  5. particular records in a file and perform operations upon them.
  6.  
  7.    This is Edition 0.15 of `The GAWK Manual',
  8. for the 2.15 version of the GNU implementation
  9. of AWK.
  10.  
  11.    Copyright (C) 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
  12.  
  13.    Permission is granted to make and distribute verbatim copies of this
  14. manual provided the copyright notice and this permission notice are
  15. preserved on all copies.
  16.  
  17.    Permission is granted to copy and distribute modified versions of
  18. this manual under the conditions for verbatim copying, provided that
  19. the entire resulting derived work is distributed under the terms of a
  20. permission notice identical to this one.
  21.  
  22.    Permission is granted to copy and distribute translations of this
  23. manual into another language, under the above conditions for modified
  24. versions, except that this permission notice may be stated in a
  25. translation approved by the Foundation.
  26.  
  27. 
  28. File: gawk.info,  Node: V7/S5R3.1,  Next: S5R4,  Prev: Language History,  Up: Language History
  29.  
  30. Major Changes between V7 and S5R3.1
  31. ===================================
  32.  
  33.    The `awk' language evolved considerably between the release of
  34. Version 7 Unix (1978) and the new version first made widely available in
  35. System V Release 3.1 (1987).  This section summarizes the changes, with
  36. cross-references to further details.
  37.  
  38.    * The requirement for `;' to separate rules on a line (*note `awk'
  39.      Statements versus Lines: Statements/Lines.).
  40.  
  41.    * User-defined functions, and the `return' statement (*note
  42.      User-defined Functions: User-defined.).
  43.  
  44.    * The `delete' statement (*note The `delete' Statement: Delete.).
  45.  
  46.    * The `do'-`while' statement (*note The `do'-`while' Statement: Do
  47.      Statement.).
  48.  
  49.    * The built-in functions `atan2', `cos', `sin', `rand' and `srand'
  50.      (*note Numeric Built-in Functions: Numeric Functions.).
  51.  
  52.    * The built-in functions `gsub', `sub', and `match' (*note Built-in
  53.      Functions for String Manipulation: String Functions.).
  54.  
  55.    * The built-in functions `close', which closes an open file, and
  56.      `system', which allows the user to execute operating system
  57.      commands (*note Built-in Functions for Input/Output: I/O
  58.      Functions.).
  59.  
  60.    * The `ARGC', `ARGV', `FNR', `RLENGTH', `RSTART', and `SUBSEP'
  61.      built-in variables (*note Built-in Variables::.).
  62.  
  63.    * The conditional expression using the operators `?' and `:' (*note
  64.      Conditional Expressions: Conditional Exp.).
  65.  
  66.    * The exponentiation operator `^' (*note Arithmetic Operators:
  67.      Arithmetic Ops.) and its assignment operator form `^=' (*note
  68.      Assignment Expressions: Assignment Ops.).
  69.  
  70.    * C-compatible operator precedence, which breaks some old `awk'
  71.      programs (*note Operator Precedence (How Operators Nest):
  72.      Precedence.).
  73.  
  74.    * Regexps as the value of `FS' (*note Specifying how Fields are
  75.      Separated: Field Separators.), and as the third argument to the
  76.      `split' function (*note Built-in Functions for String
  77.      Manipulation: String Functions.).
  78.  
  79.    * Dynamic regexps as operands of the `~' and `!~' operators (*note
  80.      How to Use Regular Expressions: Regexp Usage.).
  81.  
  82.    * Escape sequences (*note Constant Expressions: Constants.) in
  83.      regexps.
  84.  
  85.    * The escape sequences `\b', `\f', and `\r' (*note Constant
  86.      Expressions: Constants.).
  87.  
  88.    * Redirection of input for the `getline' function (*note Explicit
  89.      Input with `getline': Getline.).
  90.  
  91.    * Multiple `BEGIN' and `END' rules (*note `BEGIN' and `END' Special
  92.      Patterns: BEGIN/END.).
  93.  
  94.    * Simulated multi-dimensional arrays (*note Multi-dimensional
  95.      Arrays: Multi-dimensional.).
  96.  
  97. 
  98. File: gawk.info,  Node: S5R4,  Next: POSIX,  Prev: V7/S5R3.1,  Up: Language History
  99.  
  100. Changes between S5R3.1 and S5R4
  101. ===============================
  102.  
  103.    The System V Release 4 version of Unix `awk' added these features
  104. (some of which originated in `gawk'):
  105.  
  106.    * The `ENVIRON' variable (*note Built-in Variables::.).
  107.  
  108.    * Multiple `-f' options on the command line (*note Invoking `awk':
  109.      Command Line.).
  110.  
  111.    * The `-v' option for assigning variables before program execution
  112.      begins (*note Invoking `awk': Command Line.).
  113.  
  114.    * The `--' option for terminating command line options.
  115.  
  116.    * The `\a', `\v', and `\x' escape sequences (*note Constant
  117.      Expressions: Constants.).
  118.  
  119.    * A defined return value for the `srand' built-in function (*note
  120.      Numeric Built-in Functions: Numeric Functions.).
  121.  
  122.    * The `toupper' and `tolower' built-in string functions for case
  123.      translation (*note Built-in Functions for String Manipulation:
  124.      String Functions.).
  125.  
  126.    * A cleaner specification for the `%c' format-control letter in the
  127.      `printf' function (*note Using `printf' Statements for Fancier
  128.      Printing: Printf.).
  129.  
  130.    * The ability to dynamically pass the field width and precision
  131.      (`"%*.*d"') in the argument list of the `printf' function (*note
  132.      Using `printf' Statements for Fancier Printing: Printf.).
  133.  
  134.    * The use of constant regexps such as `/foo/' as expressions, where
  135.      they are equivalent to use of the matching operator, as in `$0 ~
  136.      /foo/' (*note Constant Expressions: Constants.).
  137.  
  138. 
  139. File: gawk.info,  Node: POSIX,  Next: POSIX/GNU,  Prev: S5R4,  Up: Language History
  140.  
  141. Changes between S5R4 and POSIX `awk'
  142. ====================================
  143.  
  144.    The POSIX Command Language and Utilities standard for `awk'
  145. introduced the following changes into the language:
  146.  
  147.    * The use of `-W' for implementation-specific options.
  148.  
  149.    * The use of `CONVFMT' for controlling the conversion of numbers to
  150.      strings (*note Conversion of Strings and Numbers: Conversion.).
  151.  
  152.    * The concept of a numeric string, and tighter comparison rules to go
  153.      with it (*note Comparison Expressions: Comparison Ops.).
  154.  
  155.    * More complete documentation of many of the previously undocumented
  156.      features of the language.
  157.  
  158. 
  159. File: gawk.info,  Node: POSIX/GNU,  Prev: POSIX,  Up: Language History
  160.  
  161. Extensions in `gawk' not in POSIX `awk'
  162. =======================================
  163.  
  164.    The GNU implementation, `gawk', adds these features:
  165.  
  166.    * The `AWKPATH' environment variable for specifying a path search for
  167.      the `-f' command line option (*note Invoking `awk': Command Line.).
  168.  
  169.    * The various `gawk' specific features available via the `-W'
  170.      command line option (*note Invoking `awk': Command Line.).
  171.  
  172.    * The `ARGIND' variable, that tracks the movement of `FILENAME'
  173.      through `ARGV'.  (*note Built-in Variables::.).
  174.  
  175.    * The `ERRNO' variable, that contains the system error message when
  176.      `getline' returns -1, or when `close' fails.  (*note Built-in
  177.      Variables::.).
  178.  
  179.    * The `IGNORECASE' variable and its effects (*note Case-sensitivity
  180.      in Matching: Case-sensitivity.).
  181.  
  182.    * The `FIELDWIDTHS' variable and its effects (*note Reading
  183.      Fixed-width Data: Constant Size.).
  184.  
  185.    * The `next file' statement for skipping to the next data file
  186.      (*note The `next file' Statement: Next File Statement.).
  187.  
  188.    * The `systime' and `strftime' built-in functions for obtaining and
  189.      printing time stamps (*note Functions for Dealing with Time
  190.      Stamps: Time Functions.).
  191.  
  192.    * The `/dev/stdin', `/dev/stdout', `/dev/stderr', and `/dev/fd/N'
  193.      file name interpretation (*note Standard I/O Streams: Special
  194.      Files.).
  195.  
  196.    * The `-W compat' option to turn off these extensions (*note
  197.      Invoking `awk': Command Line.).
  198.  
  199.    * The `-W posix' option for full POSIX compliance (*note Invoking
  200.      `awk': Command Line.).
  201.  
  202. 
  203. File: gawk.info,  Node: Installation,  Next: Gawk Summary,  Prev: Language History,  Up: Top
  204.  
  205. Installing `gawk'
  206. *****************
  207.  
  208.    This chapter provides instructions for installing `gawk' on the
  209. various platforms that are supported by the developers.  The primary
  210. developers support Unix (and one day, GNU), while the other ports were
  211. contributed.  The file `ACKNOWLEDGMENT' in the `gawk' distribution
  212. lists the electronic mail addresses of the people who did the
  213. respective ports.
  214.  
  215. * Menu:
  216.  
  217. * Gawk Distribution::           What is in the `gawk' distribution.
  218. * Unix Installation::           Installing `gawk' under various versions
  219.                                 of Unix.
  220. * VMS Installation::            Installing `gawk' on VMS.
  221. * MS-DOS Installation::         Installing `gawk' on MS-DOS.
  222. * Atari Installation::          Installing `gawk' on the Atari ST.
  223.  
  224. 
  225. File: gawk.info,  Node: Gawk Distribution,  Next: Unix Installation,  Prev: Installation,  Up: Installation
  226.  
  227. The `gawk' Distribution
  228. =======================
  229.  
  230.    This section first describes how to get and extract the `gawk'
  231. distribution, and then discusses what is in the various files and
  232. subdirectories.
  233.  
  234. * Menu:
  235.  
  236. * Extracting::                  How to get and extract the distribution.
  237. * Distribution contents::       What is in the distribution.
  238.  
  239. 
  240. File: gawk.info,  Node: Extracting,  Next: Distribution contents,  Prev: Gawk Distribution,  Up: Gawk Distribution
  241.  
  242. Getting the `gawk' Distribution
  243. -------------------------------
  244.  
  245.    `gawk' is distributed as a `tar' file compressed with the GNU Zip
  246. program, `gzip'.  You can get it via anonymous `ftp' to the Internet
  247. host `prep.ai.mit.edu'.  Like all GNU software, it will be archived at
  248. other well known systems, from which it will be possible to use some
  249. sort of anonymous `uucp' to obtain the distribution as well.  You can
  250. also order `gawk' on tape or CD-ROM directly from the Free Software
  251. Foundation.  (The address is on the copyright page.) Doing so directly
  252. contributes to the support of the foundation and to the production of
  253. more free software.
  254.  
  255.    Once you have the distribution (for example, `gawk-2.15.0.tar.z'),
  256. first use `gzip' to expand the file, and then use `tar' to extract it.
  257. You can use the following pipeline to produce the `gawk' distribution:
  258.  
  259.      # Under System V, add 'o' to the tar flags
  260.      gzip -d -c gawk-2.15.0.tar.z | tar -xvpf -
  261.  
  262. This will create a directory named `gawk-2.15' in the current directory.
  263.  
  264.    The distribution file name is of the form `gawk-2.15.N.tar.Z'.  The
  265. N represents a "patchlevel", meaning that minor bugs have been fixed in
  266. the major release.  The current patchlevel is 0, but when retrieving
  267. distributions, you should get the version with the highest patchlevel.
  268.  
  269.    If you are not on a Unix system, you will need to make other
  270. arrangements for getting and extracting the `gawk' distribution.  You
  271. should consult a local expert.
  272.  
  273. 
  274. File: gawk.info,  Node: Distribution contents,  Prev: Extracting,  Up: Gawk Distribution
  275.  
  276. Contents of the `gawk' Distribution
  277. -----------------------------------
  278.  
  279.    `gawk' has a number of C source files, documentation files,
  280. subdirectories and files related to the configuration process (*note
  281. Compiling and Installing `gawk' on Unix: Unix Installation.), and
  282. several subdirectories related to different, non-Unix, operating
  283. systems.
  284.  
  285. various `.c', `.y', and `.h' files
  286.      The C and YACC source files are the actual `gawk' source code.
  287.  
  288. `README'
  289. `README.VMS'
  290. `README.dos'
  291. `README.rs6000'
  292. `README.ultrix'
  293.      Descriptive files: `README' for `gawk' under Unix, and the rest
  294.      for the various hardware and software combinations.
  295.  
  296. `PORTS'
  297.      A list of systems to which `gawk' has been ported, and which have
  298.      successfully run the test suite.
  299.  
  300. `ACKNOWLEDGMENT'
  301.      A list of the people who contributed major parts of the code or
  302.      documentation.
  303.  
  304. `NEWS'
  305.      A list of changes to `gawk' since the last release or patch.
  306.  
  307. `COPYING'
  308.      The GNU General Public License.
  309.  
  310. `FUTURES'
  311.      A brief list of features and/or changes being contemplated for
  312.      future releases, with some indication of the time frame for the
  313.      feature, based on its difficulty.
  314.  
  315. `LIMITATIONS'
  316.      A list of those factors that limit `gawk''s performance.  Most of
  317.      these depend on the hardware or operating system software, and are
  318.      not limits in `gawk' itself.
  319.  
  320. `PROBLEMS'
  321.      A file describing known problems with the current release.
  322.  
  323. `gawk.1'
  324.      The `troff' source for a manual page describing `gawk'.
  325.  
  326. `gawk.texinfo'
  327.      The `texinfo' source file for this Info file.  It should be
  328.      processed with TeX to produce a printed manual, and with
  329.      `makeinfo' to produce the Info file.
  330.  
  331. `Makefile.in'
  332. `config'
  333. `config.in'
  334. `configure'
  335. `missing'
  336. `mungeconf'
  337.      These files and subdirectories are used when configuring `gawk'
  338.      for various Unix systems.  They are explained in detail in *Note
  339.      Compiling and Installing `gawk' on Unix: Unix Installation.
  340.  
  341. `atari'
  342.      Files needed for building `gawk' on an Atari ST.  *Note Installing
  343.      `gawk' on the Atari ST: Atari Installation, for details.
  344.  
  345. `pc'
  346.      Files needed for building `gawk' under MS-DOS.  *Note Installing
  347.      `gawk' on MS-DOS: MS-DOS Installation, for details.
  348.  
  349. `vms'
  350.      Files needed for building `gawk' under VMS.  *Note Compiling
  351.      Installing and Running `gawk' on VMS: VMS Installation, for
  352.      details.
  353.  
  354. `test'
  355.      Many interesting `awk' programs, provided as a test suite for
  356.      `gawk'.  You can use `make test' from the top level `gawk'
  357.      directory to run your version of `gawk' against the test suite.
  358.      If `gawk' successfully passes `make test' then you can be
  359.      confident of a successful port.
  360.  
  361. 
  362. File: gawk.info,  Node: Unix Installation,  Next: VMS Installation,  Prev: Gawk Distribution,  Up: Installation
  363.  
  364. Compiling and Installing `gawk' on Unix
  365. =======================================
  366.  
  367.    Often, you can compile and install `gawk' by typing only two
  368. commands.  However, if you do not use a supported system, you may need
  369. to configure `gawk' for your system yourself.
  370.  
  371. * Menu:
  372.  
  373. * Quick Installation::          Compiling `gawk' on a
  374.                                 supported Unix version.
  375. * Configuration Philosophy::    How it's all supposed to work.
  376. * New Configurations::          What to do if there is no supplied
  377.                                 configuration for your system.
  378.  
  379. 
  380. File: gawk.info,  Node: Quick Installation,  Next: Configuration Philosophy,  Prev: Unix Installation,  Up: Unix Installation
  381.  
  382. Compiling `gawk' for a Supported Unix Version
  383. ---------------------------------------------
  384.  
  385.    After you have extracted the `gawk' distribution, `cd' to
  386. `gawk-2.15'.  Look in the `config' subdirectory for a file that matches
  387. your hardware/software combination.  In general, only the software is
  388. relevant; for example `sunos41' is used for SunOS 4.1, on both Sun 3
  389. and Sun 4 hardware.
  390.  
  391.    If you find such a file, run the command:
  392.  
  393.      # assume you have SunOS 4.1
  394.      ./configure sunos41
  395.  
  396.    This produces a `Makefile' and `config.h' tailored to your system.
  397. You may wish to edit the `Makefile' to use a different C compiler, such
  398. as `gcc', the GNU C compiler, if you have it.  You may also wish to
  399. change the `CFLAGS' variable, which controls the command line options
  400. that are passed to the C compiler (such as optimization levels, or
  401. compiling for debugging).
  402.  
  403.    After you have configured `Makefile' and `config.h', type:
  404.  
  405.      make
  406.  
  407. and shortly thereafter, you should have an executable version of `gawk'.
  408. That's all there is to it!
  409.  
  410. 
  411. File: gawk.info,  Node: Configuration Philosophy,  Next: New Configurations,  Prev: Quick Installation,  Up: Unix Installation
  412.  
  413. The Configuration Process
  414. -------------------------
  415.  
  416.    (This section is of interest only if you know something about using
  417. the C language and the Unix operating system.)
  418.  
  419.    The source code for `gawk' generally attempts to adhere to industry
  420. standards wherever possible.  This means that `gawk' uses library
  421. routines that are specified by the ANSI C standard and by the POSIX
  422. operating system interface standard.  When using an ANSI C compiler,
  423. function prototypes are provided to help improve the compile-time
  424. checking.
  425.  
  426.    Many older Unix systems do not support all of either the ANSI or the
  427. POSIX standards.  The `missing' subdirectory in the `gawk' distribution
  428. contains replacement versions of those subroutines that are most likely
  429. to be missing.
  430.  
  431.    The `config.h' file that is created by the `configure' program
  432. contains definitions that describe features of the particular operating
  433. system where you are attempting to compile `gawk'.  For the most part,
  434. it lists which standard subroutines are *not* available.  For example,
  435. if your system lacks the `getopt' routine, then `GETOPT_MISSING' would
  436. be defined.
  437.  
  438.    `config.h' also defines constants that describe facts about your
  439. variant of Unix.  For example, there may not be an `st_blksize' element
  440. in the `stat' structure.  In this case `BLKSIZE_MISSING' would be
  441. defined.
  442.  
  443.    Based on the list in `config.h' of standard subroutines that are
  444. missing, `missing.c' will do a `#include' of the appropriate file(s)
  445. from the `missing' subdirectory.
  446.  
  447.    Conditionally compiled code in the other source files relies on the
  448. other definitions in the `config.h' file.
  449.  
  450.    Besides creating `config.h', `configure' produces a `Makefile' from
  451. `Makefile.in'.  There are a number of lines in `Makefile.in' that are
  452. system or feature specific.  For example, there is line that begins
  453. with `##MAKE_ALLOCA_C##'.  This is normally a comment line, since it
  454. starts with `#'.  If a configuration file has `MAKE_ALLOCA_C' in it,
  455. then `configure' will delete the `##MAKE_ALLOCA_C##' from the beginning
  456. of the line.  This will enable the rules in the `Makefile' that use a C
  457. version of `alloca'.  There are several similar features that work in
  458. this fashion.
  459.  
  460. 
  461. File: gawk.info,  Node: New Configurations,  Prev: Configuration Philosophy,  Up: Unix Installation
  462.  
  463. Configuring `gawk' for a New System
  464. -----------------------------------
  465.  
  466.    (This section is of interest only if you know something about using
  467. the C language and the Unix operating system, and if you have to install
  468. `gawk' on a system that is not supported by the `gawk' distribution.
  469. If you are a C or Unix novice, get help from a local expert.)
  470.  
  471.    If you need to configure `gawk' for a Unix system that is not
  472. supported in the distribution, first see *Note The Configuration
  473. Process: Configuration Philosophy.  Then, copy `config.in' to
  474. `config.h', and copy `Makefile.in' to `Makefile'.
  475.  
  476.    Next, edit both files.  Both files are liberally commented, and the
  477. necessary changes should be straightforward.
  478.  
  479.    While editing `config.h', you need to determine what library
  480. routines you do or do not have by consulting your system documentation,
  481. or by perusing your actual libraries using the `ar' or `nm' utilities.
  482. In the worst case, simply do not define *any* of the macros for missing
  483. subroutines.  When you compile `gawk', the final link-editing step will
  484. fail.  The link editor will provide you with a list of unresolved
  485. external references--these are the missing subroutines.  Edit
  486. `config.h' again and recompile, and you should be set.
  487.  
  488.    Editing the `Makefile' should also be straightforward.  Enable or
  489. disable the lines that begin with `##MAKE_WHATEVER##', as appropriate.
  490. Select the correct C compiler and `CFLAGS' for it.  Then run `make'.
  491.  
  492.    Getting a correct configuration is likely to be an iterative process.
  493. Do not be discouraged if it takes you several tries.  If you have no
  494. luck whatsoever, please report your system type, and the steps you took.
  495. Once you do have a working configuration, please send it to the
  496. maintainers so that support for your system can be added to the
  497. official release.
  498.  
  499.    *Note Reporting Problems and Bugs: Bugs, for information on how to
  500. report problems in configuring `gawk'.  You may also use the same
  501. mechanisms for sending in new configurations.
  502.  
  503. 
  504. File: gawk.info,  Node: VMS Installation,  Next: MS-DOS Installation,  Prev: Unix Installation,  Up: Installation
  505.  
  506. Compiling, Installing, and Running `gawk' on VMS
  507. ================================================
  508.  
  509.    This section describes how to compile and install `gawk' under VMS.
  510.  
  511. * Menu:
  512.  
  513. * VMS Compilation::             How to compile `gawk' under VMS.
  514. * VMS Installation Details::    How to install `gawk' under VMS.
  515. * VMS Running::                 How to run `gawk' under VMS.
  516. * VMS POSIX::                   Alternate instructions for VMS POSIX.
  517.  
  518. 
  519. File: gawk.info,  Node: VMS Compilation,  Next: VMS Installation Details,  Prev: VMS Installation,  Up: VMS Installation
  520.  
  521. Compiling `gawk' under VMS
  522. --------------------------
  523.  
  524.    To compile `gawk' under VMS, there is a `DCL' command procedure that
  525. will issue all the necessary `CC' and `LINK' commands, and there is
  526. also a `Makefile' for use with the `MMS' utility.  From the source
  527. directory, use either
  528.  
  529.      $ @[.VMS]VMSBUILD.COM
  530.  
  531. or
  532.  
  533.      $ MMS/DESCRIPTION=[.VMS]DECSRIP.MMS GAWK
  534.  
  535.    Depending upon which C compiler you are using, follow one of the sets
  536. of instructions in this table:
  537.  
  538. VAX C V3.x
  539.      Use either `vmsbuild.com' or `descrip.mms' as is.  These use
  540.      `CC/OPTIMIZE=NOLINE', which is essential for Version 3.0.
  541.  
  542. VAX C V2.x
  543.      You must have Version 2.3 or 2.4; older ones won't work.  Edit
  544.      either `vmsbuild.com' or `descrip.mms' according to the comments
  545.      in them.  For `vmsbuild.com', this just entails removing two `!'
  546.      delimiters.  Also edit `config.h' (which is a copy of file
  547.      `[.config]vms-conf.h') and comment out or delete the two lines
  548.      `#define __STDC__ 0' and `#define VAXC_BUILTINS' near the end.
  549.  
  550. GNU C
  551.      Edit `vmsbuild.com' or `descrip.mms'; the changes are different
  552.      from those for VAX C V2.x, but equally straightforward.  No
  553.      changes to `config.h' should be needed.
  554.  
  555. DEC C
  556.      Edit `vmsbuild.com' or `descrip.mms' according to their comments.
  557.      No changes to `config.h' should be needed.
  558.  
  559.    `gawk' 2.15 has been tested under VAX/VMS 5.5-1 using VAX C V3.2,
  560. GNU C 1.40 and 2.3.  It should work without modifications for VMS V4.6
  561. and up.
  562.  
  563. 
  564. File: gawk.info,  Node: VMS Installation Details,  Next: VMS Running,  Prev: VMS Compilation,  Up: VMS Installation
  565.  
  566. Installing `gawk' on VMS
  567. ------------------------
  568.  
  569.    To install `gawk', all you need is a "foreign" command, which is a
  570. `DCL' symbol whose value begins with a dollar sign.
  571.  
  572.      $ GAWK :== $device:[directory]GAWK
  573.  
  574. (Substitute the actual location of `gawk.exe' for
  575. `device:[directory]'.) The symbol should be placed in the `login.com'
  576. of any user who wishes to run `gawk', so that it will be defined every
  577. time the user logs on.  Alternatively, the symbol may be placed in the
  578. system-wide `sylogin.com' procedure, which will allow all users to run
  579. `gawk'.
  580.  
  581.    Optionally, the help entry can be loaded into a VMS help library:
  582.  
  583.      $ LIBRARY/HELP SYS$HELP:HELPLIB [.VMS]GAWK.HLP
  584.  
  585. (You may want to substitute a site-specific help library rather than
  586. the standard VMS library `HELPLIB'.)  After loading the help text,
  587.  
  588.      $ HELP GAWK
  589.  
  590. will provide information about both the `gawk' implementation and the
  591. `awk' programming language.
  592.  
  593.    The logical name `AWK_LIBRARY' can designate a default location for
  594. `awk' program files.  For the `-f' option, if the specified filename
  595. has no device or directory path information in it, `gawk' will look in
  596. the current directory first, then in the directory specified by the
  597. translation of `AWK_LIBRARY' if the file was not found.  If after
  598. searching in both directories, the file still is not found, then `gawk'
  599. appends the suffix `.awk' to the filename and the file search will be
  600. re-tried.  If `AWK_LIBRARY' is not defined, that portion of the file
  601. search will fail benignly.
  602.  
  603. 
  604. File: gawk.info,  Node: VMS Running,  Next: VMS POSIX,  Prev: VMS Installation Details,  Up: VMS Installation
  605.  
  606. Running `gawk' on VMS
  607. ---------------------
  608.  
  609.    Command line parsing and quoting conventions are significantly
  610. different on VMS, so examples in this manual or from other sources
  611. often need minor changes.  They *are* minor though, and all `awk'
  612. programs should run correctly.
  613.  
  614.    Here are a couple of trivial tests:
  615.  
  616.      $ gawk -- "BEGIN {print ""Hello, World!""}"
  617.      $ gawk -"W" version     ! could also be -"W version" or "-W version"
  618.  
  619. Note that upper-case and mixed-case text must be quoted.
  620.  
  621.    The VMS port of `gawk' includes a `DCL'-style interface in addition
  622. to the original shell-style interface (see the help entry for details).
  623. One side-effect of dual command line parsing is that if there is only a
  624. single parameter (as in the quoted string program above), the command
  625. becomes ambiguous.  To work around this, the normally optional `--'
  626. flag is required to force Unix style rather than `DCL' parsing.  If any
  627. other dash-type options (or multiple parameters such as data files to be
  628. processed) are present, there is no ambiguity and `--' can be omitted.
  629.  
  630.    The default search path when looking for `awk' program files
  631. specified by the `-f' option is `"SYS$DISK:[],AWK_LIBRARY:"'.  The
  632. logical name `AWKPATH' can be used to override this default.  The format
  633. of `AWKPATH' is a comma-separated list of directory specifications.
  634. When defining it, the value should be quoted so that it retains a single
  635. translation, and not a multi-translation `RMS' searchlist.
  636.  
  637. 
  638. File: gawk.info,  Node: VMS POSIX,  Prev: VMS Running,  Up: VMS Installation
  639.  
  640. Building and using `gawk' under VMS POSIX
  641. -----------------------------------------
  642.  
  643.    Ignore the instructions above, although `vms/gawk.hlp' should still
  644. be made available in a help library.  Make sure that the two scripts,
  645. `configure' and `mungeconf', are executable; use `chmod +x' on them if
  646. necessary.  Then execute the following commands:
  647.  
  648.      $ POSIX
  649.      psx> configure vms-posix
  650.      psx> make awktab.c gawk
  651.  
  652. The first command will construct files `config.h' and `Makefile' out of
  653. templates.  The second command will compile and link `gawk'.  Due to a
  654. `make' bug in VMS POSIX V1.0 and V1.1, the file `awktab.c' must be
  655. given as an explicit target or it will not be built and the final link
  656. step will fail.  Ignore the warning `"Could not find lib m in lib
  657. list"'; it is harmless, caused by the explicit use of `-lm' as a linker
  658. option which is not needed under VMS POSIX.  Under V1.1 (but not V1.0)
  659. a problem with the `yacc' skeleton `/etc/yyparse.c' will cause a
  660. compiler warning for `awktab.c', followed by a linker warning about
  661. compilation warnings in the resulting object module.  These warnings
  662. can be ignored.
  663.  
  664.    Once built, `gawk' will work like any other shell utility.  Unlike
  665. the normal VMS port of `gawk', no special command line manipulation is
  666. needed in the VMS POSIX environment.
  667.  
  668. 
  669. File: gawk.info,  Node: MS-DOS Installation,  Next: Atari Installation,  Prev: VMS Installation,  Up: Installation
  670.  
  671. Installing `gawk' on MS-DOS
  672. ===========================
  673.  
  674.    The first step is to get all the files in the `gawk' distribution
  675. onto your PC.  Move all the files from the `pc' directory into the main
  676. directory where the other files are.  Edit the file `make.bat' so that
  677. it will be an acceptable MS-DOS batch file.  This means making sure
  678. that all lines are terminated with the ASCII carriage return and line
  679. feed characters.  restrictions.
  680.  
  681.    `gawk' has only been compiled with version 5.1 of the Microsoft C
  682. compiler.  The file `make.bat' from the `pc' directory assumes that you
  683. have this compiler.
  684.  
  685.    Copy the file `setargv.obj' from the library directory where it
  686. resides to the `gawk' source code directory.
  687.  
  688.    Run `make.bat'.  This will compile `gawk' for you, and link it.
  689. That's all there is to it!
  690.  
  691. 
  692. File: gawk.info,  Node: Atari Installation,  Prev: MS-DOS Installation,  Up: Installation
  693.  
  694. Installing `gawk' on the Atari ST
  695. =================================
  696.  
  697.    This section assumes that you are running TOS.  It applies to other
  698. Atari models (STe, TT) as well.
  699.  
  700.    In order to use `gawk', you need to have a shell, either text or
  701. graphics, that does not map all the characters of a command line to
  702. upper case.  Maintaining case distinction in option flags is very
  703. important (*note Invoking `awk': Command Line.).  Popular shells like
  704. `gulam' or `gemini' will work, as will newer versions of `desktop'.
  705. Support for I/O redirection is necessary to make it easy to import
  706. `awk' programs from other environments.  Pipes are nice to have, but
  707. not vital.
  708.  
  709.    If you have received an executable version of `gawk', place it, as
  710. usual, anywhere in your `PATH' where your shell will find it.
  711.  
  712.    While executing, `gawk' creates a number of temporary files.  `gawk'
  713. looks for either of the environment variables `TEMP' or `TMPDIR', in
  714. that order.  If either one is found, its value is assumed to be a
  715. directory for temporary files.  This directory must exist, and if you
  716. can spare the memory, it is a good idea to put it on a RAM drive.  If
  717. neither `TEMP' nor `TMPDIR' are found, then `gawk' uses the current
  718. directory for its temporary files.
  719.  
  720.    The ST version of `gawk' searches for its program files as described
  721. in *Note The `AWKPATH' Environment Variable: AWKPATH Variable.  On the
  722. ST, the default value for the `AWKPATH' variable is
  723. `".,c:\lib\awk,c:\gnu\lib\awk"'.  The search path can be modified by
  724. explicitly setting `AWKPATH' to whatever you wish.  Note that colons
  725. cannot be used on the ST to separate elements in the `AWKPATH'
  726. variable, since they have another, reserved, meaning.  Instead, you
  727. must use a comma to separate elements in the path.  If you are
  728. recompiling `gawk' on the ST, then you can choose a new default search
  729. path, by setting the value of `DEFPATH' in the file `...\config\atari'.
  730. You may choose a different separator character by setting the value of
  731. `ENVSEP' in the same file.  The new values will be used when creating
  732. the header file `config.h'.
  733.  
  734.    Although `awk' allows great flexibility in doing I/O redirections
  735. from within a program, this facility should be used with care on the ST.
  736. In some circumstances the OS routines for file handle pool processing
  737. lose track of certain events, causing the computer to crash, and
  738. requiring a reboot.  Often a warm reboot is sufficient.  Fortunately,
  739. this happens infrequently, and in rather esoteric situations.  In
  740. particular, avoid having one part of an `awk' program using `print'
  741. statements explicitly redirected to `"/dev/stdout"', while other
  742. `print' statements use the default standard output, and a calling shell
  743. has redirected standard output to a file.
  744.  
  745.    When `gawk' is compiled with the ST version of `gcc' and its usual
  746. libraries, it will accept both `/' and `\' as path separators.  While
  747. this is convenient, it should be remembered that this removes one,
  748. technically legal, character (`/') from your file names, and that it
  749. may create problems for external programs, called via the `system()'
  750. function, which may not support this convention.  Whenever it is
  751. possible that a file created by `gawk' will be used by some other
  752. program, use only backslashes.  Also remember that in `awk',
  753. backslashes in strings have to be doubled in order to get literal
  754. backslashes.
  755.  
  756.    The initial port of `gawk' to the ST was done with `gcc'.  If you
  757. wish to recompile `gawk' from scratch, you will need to use a compiler
  758. that accepts ANSI standard C (such as `gcc', Turbo C, or Prospero C).
  759. If `sizeof(int) != sizeof(int *)', the correctness of the generated
  760. code depends heavily on the fact that all function calls have function
  761. prototypes in the current scope.  If your compiler does not accept
  762. function prototypes, you will probably have to add a number of casts to
  763. the code.
  764.  
  765.    If you are using `gcc', make sure that you have up-to-date libraries.
  766. Older versions have problems with some library functions (`atan2()',
  767. `strftime()', the `%g' conversion in `sprintf()') which may affect the
  768. operation of `gawk'.
  769.  
  770.    In the `atari' subdirectory of the `gawk' distribution is a version
  771. of the `system()' function that has been tested with `gulam' and `msh';
  772. it should work with other shells as well.  With `gulam', it passes the
  773. string to be executed without spawning an extra copy of a shell.  It is
  774. possible to replace this version of `system()' with a similar function
  775. from a library or from some other source if that version would be a
  776. better choice for the shell you prefer.
  777.  
  778.    The files needed to recompile `gawk' on the ST can be found in the
  779. `atari' directory.  The provided files and instructions below assume
  780. that you have the GNU C compiler (`gcc'), the `gulam' shell, and an ST
  781. version of `sed'. The `Makefile' is set up to use `byacc' as a `yacc'
  782. replacement.  With a different set of tools some adjustments and/or
  783. editing will be needed.
  784.  
  785.    `cd' to the `atari' directory.  Copy `Makefile.st' to `makefile' in
  786. the source (parent) directory.  Possibly adjust `../config/atari' to
  787. suit your system.  Execute the script `mkconf.g' which will create the
  788. header file `../config.h'.  Go back to the source directory.  If you
  789. are not using `gcc', check the file `missing.c'.  It may be necessary
  790. to change forward slashes in the references to files from the `atari'
  791. subdirectory into backslashes.  Type `make' and enjoy.
  792.  
  793.    Compilation with `gcc' of some of the bigger modules, like
  794. `awk_tab.c', may require a full four megabytes of memory.  On smaller
  795. machines you would need to cut down on optimizations, or you would have
  796. to switch to another, less memory hungry, compiler.
  797.  
  798. 
  799. File: gawk.info,  Node: Gawk Summary,  Next: Sample Program,  Prev: Installation,  Up: Top
  800.  
  801. `gawk' Summary
  802. **************
  803.  
  804.    This appendix provides a brief summary of the `gawk' command line
  805. and the `awk' language.  It is designed to serve as "quick reference."
  806. It is therefore terse, but complete.
  807.  
  808. * Menu:
  809.  
  810. * Command Line Summary::        Recapitulation of the command line.
  811. * Language Summary::            A terse review of the language.
  812. * Variables/Fields::            Variables, fields, and arrays.
  813. * Rules Summary::               Patterns and Actions, and their
  814.                                 component parts.
  815. * Functions Summary::           Defining and calling functions.
  816. * Historical Features::         Some undocumented but supported "features".
  817.  
  818. 
  819. File: gawk.info,  Node: Command Line Summary,  Next: Language Summary,  Prev: Gawk Summary,  Up: Gawk Summary
  820.  
  821. Command Line Options Summary
  822. ============================
  823.  
  824.    The command line consists of options to `gawk' itself, the `awk'
  825. program text (if not supplied via the `-f' option), and values to be
  826. made available in the `ARGC' and `ARGV' predefined `awk' variables:
  827.  
  828.      awk [POSIX OR GNU STYLE OPTIONS] -f source-file [`--'] FILE ...
  829.      awk [POSIX OR GNU STYLE OPTIONS] [`--'] 'PROGRAM' FILE ...
  830.  
  831.    The options that `gawk' accepts are:
  832.  
  833. `-F FS'
  834. `--field-separator=FS'
  835.      Use FS for the input field separator (the value of the `FS'
  836.      predefined variable).
  837.  
  838. `-f PROGRAM-FILE'
  839. `--file=PROGRAM-FILE'
  840.      Read the `awk' program source from the file PROGRAM-FILE, instead
  841.      of from the first command line argument.
  842.  
  843. `-v VAR=VAL'
  844. `--assign=VAR=VAL'
  845.      Assign the variable VAR the value VAL before program execution
  846.      begins.
  847.  
  848. `-W compat'
  849. `--compat'
  850.      Specifies compatibility mode, in which `gawk' extensions are turned
  851.      off.
  852.  
  853. `-W copyleft'
  854. `-W copyright'
  855. `--copyleft'
  856. `--copyright'
  857.      Print the short version of the General Public License on the error
  858.      output.  This option may disappear in a future version of `gawk'.
  859.  
  860. `-W help'
  861. `-W usage'
  862. `--help'
  863. `--usage'
  864.      Print a relatively short summary of the available options on the
  865.      error output.
  866.  
  867. `-W lint'
  868. `--lint'
  869.      Give warnings about dubious or non-portable `awk' constructs.
  870.  
  871. `-W posix'
  872. `--posix'
  873.      Specifies POSIX compatibility mode, in which `gawk' extensions are
  874.      turned off and additional restrictions apply.
  875.  
  876. `-W source=PROGRAM-TEXT'
  877. `--source=PROGRAM-TEXT'
  878.      Use PROGRAM-TEXT as `awk' program source code.  This option allows
  879.      mixing command line source code with source code from files, and is
  880.      particularly useful for mixing command line programs with library
  881.      functions.
  882.  
  883. `-W version'
  884. `--version'
  885.      Print version information for this particular copy of `gawk' on
  886.      the error output.  This option may disappear in a future version
  887.      of `gawk'.
  888.  
  889. `--'
  890.      Signal the end of options.  This is useful to allow further
  891.      arguments to the `awk' program itself to start with a `-'.  This
  892.      is mainly for consistency with the argument parsing conventions of
  893.      POSIX.
  894.  
  895.    Any other options are flagged as invalid, but are otherwise ignored.
  896. *Note Invoking `awk': Command Line, for more details.
  897.  
  898. 
  899. File: gawk.info,  Node: Language Summary,  Next: Variables/Fields,  Prev: Command Line Summary,  Up: Gawk Summary
  900.  
  901. Language Summary
  902. ================
  903.  
  904.    An `awk' program consists of a sequence of pattern-action statements
  905. and optional function definitions.
  906.  
  907.      PATTERN    { ACTION STATEMENTS }
  908.      
  909.      function NAME(PARAMETER LIST)     { ACTION STATEMENTS }
  910.  
  911.    `gawk' first reads the program source from the PROGRAM-FILE(s) if
  912. specified, or from the first non-option argument on the command line.
  913. The `-f' option may be used multiple times on the command line.  `gawk'
  914. reads the program text from all the PROGRAM-FILE files, effectively
  915. concatenating them in the order they are specified.  This is useful for
  916. building libraries of `awk' functions, without having to include them
  917. in each new `awk' program that uses them.  To use a library function in
  918. a file from a program typed in on the command line, specify `-f
  919. /dev/tty'; then type your program, and end it with a `Control-d'.
  920. *Note Invoking `awk': Command Line.
  921.  
  922.    The environment variable `AWKPATH' specifies a search path to use
  923. when finding source files named with the `-f' option.  The default
  924. path, which is `.:/local/lib/awk:/gnu/lib/awk' is used if `AWKPATH' is
  925. not set.  If a file name given to the `-f' option contains a `/'
  926. character, no path search is performed.  *Note The `AWKPATH'
  927. Environment Variable: AWKPATH Variable, for a full description of the
  928. `AWKPATH' environment variable.
  929.  
  930.    `gawk' compiles the program into an internal form, and then proceeds
  931. to read each file named in the `ARGV' array.  If there are no files
  932. named on the command line, `gawk' reads the standard input.
  933.  
  934.    If a "file" named on the command line has the form `VAR=VAL', it is
  935. treated as a variable assignment: the variable VAR is assigned the
  936. value VAL.  If any of the files have a value that is the null string,
  937. that element in the list is skipped.
  938.  
  939.    For each line in the input, `gawk' tests to see if it matches any
  940. PATTERN in the `awk' program.  For each pattern that the line matches,
  941. the associated ACTION is executed.
  942.  
  943. 
  944. File: gawk.info,  Node: Variables/Fields,  Next: Rules Summary,  Prev: Language Summary,  Up: Gawk Summary
  945.  
  946. Variables and Fields
  947. ====================
  948.  
  949.    `awk' variables are dynamic; they come into existence when they are
  950. first used.  Their values are either floating-point numbers or strings.
  951. `awk' also has one-dimension arrays; multiple-dimensional arrays may be
  952. simulated.  There are several predefined variables that `awk' sets as a
  953. program runs; these are summarized below.
  954.  
  955. * Menu:
  956.  
  957. * Fields Summary::              Input field splitting.
  958. * Built-in Summary::            `awk''s built-in variables.
  959. * Arrays Summary::              Using arrays.
  960. * Data Type Summary::           Values in `awk' are numbers or strings.
  961.  
  962. 
  963. File: gawk.info,  Node: Fields Summary,  Next: Built-in Summary,  Prev: Variables/Fields,  Up: Variables/Fields
  964.  
  965. Fields
  966. ------
  967.  
  968.    As each input line is read, `gawk' splits the line into FIELDS,
  969. using the value of the `FS' variable as the field separator.  If `FS'
  970. is a single character, fields are separated by that character.
  971. Otherwise, `FS' is expected to be a full regular expression.  In the
  972. special case that `FS' is a single blank, fields are separated by runs
  973. of blanks and/or tabs.  Note that the value of `IGNORECASE' (*note
  974. Case-sensitivity in Matching: Case-sensitivity.) also affects how
  975. fields are split when `FS' is a regular expression.
  976.  
  977.    Each field in the input line may be referenced by its position, `$1',
  978. `$2', and so on.  `$0' is the whole line.  The value of a field may be
  979. assigned to as well.  Field numbers need not be constants:
  980.  
  981.      n = 5
  982.      print $n
  983.  
  984. prints the fifth field in the input line.  The variable `NF' is set to
  985. the total number of fields in the input line.
  986.  
  987.    References to nonexistent fields (i.e., fields after `$NF') return
  988. the null-string.  However, assigning to a nonexistent field (e.g.,
  989. `$(NF+2) = 5') increases the value of `NF', creates any intervening
  990. fields with the null string as their value, and causes the value of
  991. `$0' to be recomputed, with the fields being separated by the value of
  992. `OFS'.
  993.  
  994.    *Note Reading Input Files: Reading Files, for a full description of
  995. the way `awk' defines and uses fields.
  996.  
  997. 
  998. File: gawk.info,  Node: Built-in Summary,  Next: Arrays Summary,  Prev: Fields Summary,  Up: Variables/Fields
  999.  
  1000. Built-in Variables
  1001. ------------------
  1002.  
  1003.    `awk''s built-in variables are:
  1004.  
  1005. `ARGC'
  1006.      The number of command line arguments (not including options or the
  1007.      `awk' program itself).
  1008.  
  1009. `ARGIND'
  1010.      The index in `ARGV' of the current file being processed.  It is
  1011.      always true that `FILENAME == ARGV[ARGIND]'.
  1012.  
  1013. `ARGV'
  1014.      The array of command line arguments.  The array is indexed from 0
  1015.      to `ARGC' - 1.  Dynamically changing the contents of `ARGV' can
  1016.      control the files used for data.
  1017.  
  1018. `CONVFMT'
  1019.      The conversion format to use when converting numbers to strings.
  1020.  
  1021. `FIELDWIDTHS'
  1022.      A space separated list of numbers describing the fixed-width input
  1023.      data.
  1024.  
  1025. `ENVIRON'
  1026.      An array containing the values of the environment variables.  The
  1027.      array is indexed by variable name, each element being the value of
  1028.      that variable.  Thus, the environment variable `HOME' would be in
  1029.      `ENVIRON["HOME"]'.  Its value might be `/u/close'.
  1030.  
  1031.      Changing this array does not affect the environment seen by
  1032.      programs which `gawk' spawns via redirection or the `system'
  1033.      function.  (This may change in a future version of `gawk'.)
  1034.  
  1035.      Some operating systems do not have environment variables.  The
  1036.      array `ENVIRON' is empty when running on these systems.
  1037.  
  1038. `ERRNO'
  1039.      The system error message when an error occurs using `getline' or
  1040.      `close'.
  1041.  
  1042. `FILENAME'
  1043.      The name of the current input file.  If no files are specified on
  1044.      the command line, the value of `FILENAME' is `-'.
  1045.  
  1046. `FNR'
  1047.      The input record number in the current input file.
  1048.  
  1049. `FS'
  1050.      The input field separator, a blank by default.
  1051.  
  1052. `IGNORECASE'
  1053.      The case-sensitivity flag for regular expression operations.  If
  1054.      `IGNORECASE' has a nonzero value, then pattern matching in rules,
  1055.      field splitting with `FS', regular expression matching with `~'
  1056.      and `!~', and the `gsub', `index', `match', `split' and `sub'
  1057.      predefined functions all ignore case when doing regular expression
  1058.      operations.
  1059.  
  1060. `NF'
  1061.      The number of fields in the current input record.
  1062.  
  1063. `NR'
  1064.      The total number of input records seen so far.
  1065.  
  1066. `OFMT'
  1067.      The output format for numbers for the `print' statement, `"%.6g"'
  1068.      by default.
  1069.  
  1070. `OFS'
  1071.      The output field separator, a blank by default.
  1072.  
  1073. `ORS'
  1074.      The output record separator, by default a newline.
  1075.  
  1076. `RS'
  1077.      The input record separator, by default a newline.  `RS' is
  1078.      exceptional in that only the first character of its string value
  1079.      is used for separating records.  If `RS' is set to the null
  1080.      string, then records are separated by blank lines.  When `RS' is
  1081.      set to the null string, then the newline character always acts as
  1082.      a field separator, in addition to whatever value `FS' may have.
  1083.  
  1084. `RSTART'
  1085.      The index of the first character matched by `match'; 0 if no match.
  1086.  
  1087. `RLENGTH'
  1088.      The length of the string matched by `match'; -1 if no match.
  1089.  
  1090. `SUBSEP'
  1091.      The string used to separate multiple subscripts in array elements,
  1092.      by default `"\034"'.
  1093.  
  1094.    *Note Built-in Variables::, for more information.
  1095.  
  1096. 
  1097. File: gawk.info,  Node: Arrays Summary,  Next: Data Type Summary,  Prev: Built-in Summary,  Up: Variables/Fields
  1098.  
  1099. Arrays
  1100. ------
  1101.  
  1102.    Arrays are subscripted with an expression between square brackets
  1103. (`[' and `]').  Array subscripts are *always* strings; numbers are
  1104. converted to strings as necessary, following the standard conversion
  1105. rules (*note Conversion of Strings and Numbers: Conversion.).
  1106.  
  1107.    If you use multiple expressions separated by commas inside the square
  1108. brackets, then the array subscript is a string consisting of the
  1109. concatenation of the individual subscript values, converted to strings,
  1110. separated by the subscript separator (the value of `SUBSEP').
  1111.  
  1112.    The special operator `in' may be used in an `if' or `while'
  1113. statement to see if an array has an index consisting of a particular
  1114. value.
  1115.  
  1116.      if (val in array)
  1117.              print array[val]
  1118.  
  1119.    If the array has multiple subscripts, use `(i, j, ...) in array' to
  1120. test for existence of an element.
  1121.  
  1122.    The `in' construct may also be used in a `for' loop to iterate over
  1123. all the elements of an array.  *Note Scanning all Elements of an Array:
  1124. Scanning an Array.
  1125.  
  1126.    An element may be deleted from an array using the `delete' statement.
  1127.  
  1128.    *Note Arrays in `awk': Arrays, for more detailed information.
  1129.  
  1130. 
  1131. File: gawk.info,  Node: Data Type Summary,  Prev: Arrays Summary,  Up: Variables/Fields
  1132.  
  1133. Data Types
  1134. ----------
  1135.  
  1136.    The value of an `awk' expression is always either a number or a
  1137. string.
  1138.  
  1139.    Certain contexts (such as arithmetic operators) require numeric
  1140. values.  They convert strings to numbers by interpreting the text of
  1141. the string as a numeral.  If the string does not look like a numeral,
  1142. it converts to 0.
  1143.  
  1144.    Certain contexts (such as concatenation) require string values.
  1145. They convert numbers to strings by effectively printing them with
  1146. `sprintf'.  *Note Conversion of Strings and Numbers: Conversion, for
  1147. the details.
  1148.  
  1149.    To force conversion of a string value to a number, simply add 0 to
  1150. it.  If the value you start with is already a number, this does not
  1151. change it.
  1152.  
  1153.    To force conversion of a numeric value to a string, concatenate it
  1154. with the null string.
  1155.  
  1156.    The `awk' language defines comparisons as being done numerically if
  1157. both operands are numeric, or if one is numeric and the other is a
  1158. numeric string.  Otherwise one or both operands are converted to
  1159. strings and a string comparison is performed.
  1160.  
  1161.    Uninitialized variables have the string value `""' (the null, or
  1162. empty, string).  In contexts where a number is required, this is
  1163. equivalent to 0.
  1164.  
  1165.    *Note Variables::, for more information on variable naming and
  1166. initialization; *note Conversion of Strings and Numbers: Conversion.,
  1167. for more information on how variable values are interpreted.
  1168.  
  1169. 
  1170. File: gawk.info,  Node: Rules Summary,  Next: Functions Summary,  Prev: Variables/Fields,  Up: Gawk Summary
  1171.  
  1172. Patterns and Actions
  1173. ====================
  1174.  
  1175. * Menu:
  1176.  
  1177. * Pattern Summary::             Quick overview of patterns.
  1178. * Regexp Summary::              Quick overview of regular expressions.
  1179. * Actions Summary::             Quick overview of actions.
  1180.  
  1181.    An `awk' program is mostly composed of rules, each consisting of a
  1182. pattern followed by an action.  The action is enclosed in `{' and `}'.
  1183. Either the pattern may be missing, or the action may be missing, but,
  1184. of course, not both.  If the pattern is missing, the action is executed
  1185. for every single line of input.  A missing action is equivalent to this
  1186. action,
  1187.  
  1188.      { print }
  1189.  
  1190. which prints the entire line.
  1191.  
  1192.    Comments begin with the `#' character, and continue until the end of
  1193. the line.  Blank lines may be used to separate statements.  Normally, a
  1194. statement ends with a newline, however, this is not the case for lines
  1195. ending in a `,', `{', `?', `:', `&&', or `||'.  Lines ending in `do' or
  1196. `else' also have their statements automatically continued on the
  1197. following line.  In other cases, a line can be continued by ending it
  1198. with a `\', in which case the newline is ignored.
  1199.  
  1200.    Multiple statements may be put on one line by separating them with a
  1201. `;'.  This applies to both the statements within the action part of a
  1202. rule (the usual case), and to the rule statements.
  1203.  
  1204.    *Note Comments in `awk' Programs: Comments, for information on
  1205. `awk''s commenting convention; *note `awk' Statements versus Lines:
  1206. Statements/Lines., for a description of the line continuation mechanism
  1207. in `awk'.
  1208.  
  1209. 
  1210. File: gawk.info,  Node: Pattern Summary,  Next: Regexp Summary,  Prev: Rules Summary,  Up: Rules Summary
  1211.  
  1212. Patterns
  1213. --------
  1214.  
  1215.    `awk' patterns may be one of the following:
  1216.  
  1217.      /REGULAR EXPRESSION/
  1218.      RELATIONAL EXPRESSION
  1219.      PATTERN && PATTERN
  1220.      PATTERN || PATTERN
  1221.      PATTERN ? PATTERN : PATTERN
  1222.      (PATTERN)
  1223.      ! PATTERN
  1224.      PATTERN1, PATTERN2
  1225.      BEGIN
  1226.      END
  1227.  
  1228.    `BEGIN' and `END' are two special kinds of patterns that are not
  1229. tested against the input.  The action parts of all `BEGIN' rules are
  1230. merged as if all the statements had been written in a single `BEGIN'
  1231. rule.  They are executed before any of the input is read.  Similarly,
  1232. all the `END' rules are merged, and executed when all the input is
  1233. exhausted (or when an `exit' statement is executed).  `BEGIN' and `END'
  1234. patterns cannot be combined with other patterns in pattern expressions.
  1235. `BEGIN' and `END' rules cannot have missing action parts.
  1236.  
  1237.    For `/REGULAR-EXPRESSION/' patterns, the associated statement is
  1238. executed for each input line that matches the regular expression.
  1239. Regular expressions are extensions of those in `egrep', and are
  1240. summarized below.
  1241.  
  1242.    A RELATIONAL EXPRESSION may use any of the operators defined below in
  1243. the section on actions.  These generally test whether certain fields
  1244. match certain regular expressions.
  1245.  
  1246.    The `&&', `||', and `!' operators are logical "and," logical "or,"
  1247. and logical "not," respectively, as in C.  They do short-circuit
  1248. evaluation, also as in C, and are used for combining more primitive
  1249. pattern expressions.  As in most languages, parentheses may be used to
  1250. change the order of evaluation.
  1251.  
  1252.    The `?:' operator is like the same operator in C.  If the first
  1253. pattern matches, then the second pattern is matched against the input
  1254. record; otherwise, the third is matched.  Only one of the second and
  1255. third patterns is matched.
  1256.  
  1257.    The `PATTERN1, PATTERN2' form of a pattern is called a range
  1258. pattern.  It matches all input lines starting with a line that matches
  1259. PATTERN1, and continuing until a line that matches PATTERN2, inclusive.
  1260. A range pattern cannot be used as an operand to any of the pattern
  1261. operators.
  1262.  
  1263.    *Note Patterns::, for a full description of the pattern part of `awk'
  1264. rules.
  1265.  
  1266.