aboutsummaryrefslogtreecommitdiffstats
path: root/doc/awkcard.in
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2010-07-16 12:49:45 +0300
committerArnold D. Robbins <arnold@skeeve.com>2010-07-16 12:49:45 +0300
commit6607eb3d5e40b98d2acc8f6b0d6a0b5a4b0f56bd (patch)
treec1eb39be8cc5c19101385e171ec0c58f95d521cc /doc/awkcard.in
parent6719bb6e1c5576e857ab6fc121ec31a75161a3e7 (diff)
downloadegawk-6607eb3d5e40b98d2acc8f6b0d6a0b5a4b0f56bd.tar.gz
egawk-6607eb3d5e40b98d2acc8f6b0d6a0b5a4b0f56bd.tar.bz2
egawk-6607eb3d5e40b98d2acc8f6b0d6a0b5a4b0f56bd.zip
Move to gawk-3.0.3.
Diffstat (limited to 'doc/awkcard.in')
-rw-r--r--doc/awkcard.in851
1 files changed, 519 insertions, 332 deletions
diff --git a/doc/awkcard.in b/doc/awkcard.in
index b68f01d8..4a02c878 100644
--- a/doc/awkcard.in
+++ b/doc/awkcard.in
@@ -1,6 +1,6 @@
.\" AWK Reference Card --- Arnold Robbins, arnold@gnu.ai.mit.edu
.\"
-.\" Copyright (C) 1996 Free Software Foundation, Inc.
+.\" Copyright (C) 1996, 97 Free Software Foundation, Inc.
.\"
.\" Permission is granted to make and distribute verbatim copies of
.\" this reference card provided the copyright notice and this permission
@@ -28,7 +28,12 @@
.ds MK \*(FCmawk\*(FR
.\"
.\"
-
+.de TD\" tab defaults
+.ta .2i .78i 1i 1.2i 1.4i 1.7i
+..
+.de TE
+.TD
+..
.sp
.ce
@@ -50,12 +55,12 @@ Command Line Arguments (\*(MK) 4
Conversions And Comparisons 10
Copying Permissions 16
Definitions 2
-Environment Variables (\*(GK) 16
+Environment Variables 16
Escape Sequences 7
Expressions 9
Fields 6
FTP Information 16
-Historical Features 16
+Historical Features (\*(GK) 16
Input Control 11
Lines And Statements 5
.ig
@@ -70,17 +75,17 @@ Records 6
Regular Expressions 5
Special Filenames 13
String Functions 14
-Time Functions 15
+Time Functions (\*(GK) 15
User-defined Functions 15
Variables 8\*(CX
.in -.2i
.EB "\s+2\f(HBCONTENTS\*(FR\s0"
.sp
-.ta .2i .78i 1i 1.2i 1.4i 1.7i
+.TD
.fi
\*(CD\*(FRThis reference card was written by Arnold Robbins.
Brian Kernighan and Michael Brennan reviewed it; we thank them
-them for their help.
+for their help.
.sp
.SL
.sp
@@ -90,7 +95,7 @@ them for their help.
\*(CD
.SL
.nf
-\*(FR\(co Copyright, 1996 Free Software Foundation
+\*(FR\(co Copyright, 1996, 1997 Free Software Foundation
59 Temple Place \(em Suite 330
Boston, MA 02111-1307 USA
.nf
@@ -104,7 +109,7 @@ Boston, MA 02111-1307 USA
.ES
\*(CDThis card describes POSIX AWK, as well as the three
freely available \*(AK implementations
-(see \fHFTP Information\fP, below).
+(see \fHFTP Information\fP below).
\*(CLCommon extensions (in two or more versions) are printed in light blue.
\*(CBFeatures specific to just one version\(emusually GNU AWK (\*(GK)\(emare
printed in dark blue.
@@ -113,11 +118,15 @@ printed in dark blue.
.sp .5
Several type faces are used to clarify the meaning:
.br
+.nr IN \w'\(bu '
\(bu \*(FC\*(CN\fP is used for computer input.
.br
+.fi
+.in +\n(INu
+.ti -\n(INu
\(bu\|\^\*(FI\*(IN\fP is used to indicate user input and for syntactic
-.br
-\0\|\^placeholders, such as \*(FIvariable\fP or \*(FIaction\fP.
+placeholders, such as \*(FIvariable\fP or \*(FIaction\fP.
+.in -\n(INu
.br
\(bu \*(RN is used for explanatory text.
.sp .5
@@ -125,13 +134,13 @@ Several type faces are used to clarify the meaning:
\*(FC3\*(FR,
\*(FC2.3\*(FR,
\*(FC.4\*(FR,
-\*(FC1.4e2\*(FR,
+\*(FC1.4e2\*(FR
or
\*(FC4.1E5\*(FR.
.sp .5
\*(FIescape sequences\fP \- a special sequence of characters beginning
with a backslash, used to describe otherwise unprintable characters.
-See \fHEscape Sequences\fP, below.
+(See \fHEscape Sequences\fP below.)
.sp .5
\*(FIstring\fP \- a group of characters enclosed in double quotes.
Strings may contain \*(FIescape sequences\*(FR.
@@ -140,7 +149,7 @@ Strings may contain \*(FIescape sequences\*(FR.
enclosed in forward slashes, or a dynamic regexp computed at run-time.
Regexp constants may contain \*(FIescape sequences\*(FR.
.sp .5
-\*(FIname\fP \- a variable, array, or function name.
+\*(FIname\fP \- a variable, array or function name.
.sp .5
\*(FIentry\fP(\*(FIN\fP) \- entry \*(FIentry\fP in section \*(FIN\fP of the
UNIX reference manual.
@@ -153,7 +162,6 @@ UNIX reference manual.
be missing.\*(CX
.EB \s+2\f(HBDEFINITIONS\*(FR\s0
-
.\" --- Command Line Arguments
.ES
.fi
@@ -161,84 +169,115 @@ be missing.\*(CX
setting variables before the \*(FCBEGIN\fP rule is run, and
the location of AWK program source code.
Implementation-specific command line arguments change
-the behaviour of the running interpreter.
+the behavior of the running interpreter.
.sp .5
-.nf
-\*(FC\-F \*(FIfs\*(FR use \*(FIfs\fP for the input field separator
-\*(FC\-v\*(FI var\*(FC\^=\^\*(FIval\*(FR assign the value \*(FIval\*(FR, to the variable \*(FIvar\*(FR,
- before execution of the program begins. Such
- variable values are available to the \*(FCBEGIN\fP rule
-\*(FC\-f \*(FIprog-file\*(FR read the AWK program source from the file
- \*(FIprog-file\*(FR, instead of from the first command
- line argument. Multiple \*(FC\-f\*(FR options may be used
-\*(FC\-\^\-\*(FR signal the end of options
+.TS
+expand;
+l lw(2.2i).
+\*(FC\-F \*(FIfs\*(FR use \*(FIfs\fP for the input field separator.
+\*(FC\-v\*(FI var\*(FC\^=\^\*(FIval\*(FR T{
+assign the value \*(FIval\*(FR, to the variable \*(FIvar\*(FR,
+before execution of the program begins. Such
+variable values are available to the \*(FCBEGIN\fP rule.
+T}
+\*(FC\-f \*(FIprog-file\*(FR T{
+read the AWK program source from the file
+\*(FIprog-file\*(FR, instead of from the first command
+line argument. Multiple \*(FC\-f\*(FR options may be used.
+T}
+\*(FC\-\^\-\*(FR signal the end of options.
+.TE
.sp .5
.fi
\*(CLThe following options are accepted by both \*(NK and \*(GK
\*(CR(ignored by \*(GK, not in \*(MK).\*(CL
.sp .5
.nf
-\*(FC\-mf \*(FIval\*(FR set the maximum number of fields to \*(FIval\fP
-\*(FC\-mr \*(FIval\*(FR set the maximum record size to \*(FIval\fP\*(CX
+.TS
+expand, tab(%);
+l lw(2.2i).
+\*(FC\-mf \*(FIval\*(FR%set the maximum number of fields to \*(FIval\fP
+\*(FC\-mr \*(FIval\*(FR%set the maximum record size to \*(FIval\fP\*(CX
+.TE
.EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (standard)\*(FR\s0"
.BT
-
-
.ES
.fi
\*(CDThe following options are specific to \*(GK. The \*(FC\-W\*(FR
forms are for full POSIX compliance.
.sp .5
-.nf
+.ig
+.\" This option is left undocumented, on purpose.
+\*(FC\-\^\-nostalgia\*(FR
+\*(FC\-W nostalgia\*(FR%T{
+provide a moment of nostalgia for
+long time \*(AK users.
+T}
+..
+.TS
+expand, tab(%);
+ls
+l lw(1.8i).
\*(FC\-\^\-field-separator \*(FIfs\*(FR
- just like \*(FC\-F\fP
-\*(FC\-\^\-assign \*(FIvar\*(FC\^=\^\*(FIval\*(FR just like \*(FC\-v\fP
-\*(FC\-\^\-file \*(FIprog-file \*(FRjust like \*(FC\-f\fP
+%just like \*(FC\-F\fP
+\*(FC\-\^\-assign \*(FIvar\*(FC\^=\^\*(FIval\*(FR%just like \*(FC\-v\fP
+\*(FC\-\^\-file \*(FIprog-file%\*(FRjust like \*(FC\-f\fP
\*(FC\-\^\-traditional\*(FR
\*(FC\-\^\-compat\*(FR
\*(FC\-W compat\*(FR
-\*(FC\-W traditional\*(FR turn off \*(GK-specific extensions
- (\*(FC\-\^\-traditional\*(FR preferred)
+\*(FC\-W traditional\*(FR%T{
+turn off \*(GK-specific extensions
+(\*(FC\-\^\-traditional\*(FR preferred).
+T}
\*(FC\-\^\-copyleft\*(FR
\*(FC\-\^\-copyright\*(FR
\*(FC\-W copyleft\*(FR
-\*(FC\-W copyright\*(FR print the short version of the GNU
- copyright information on \*(FCstdout\*(FR
+\*(FC\-W copyright\*(FR%T{
+print the short version of the GNU
+copyright information on \*(FCstdout\*(FR.
+T}
\*(FC\-\^\-help\*(FR
\*(FC\-\^\-usage\*(FR
\*(FC\-W help\*(FR
-\*(FC\-W usage\*(FR Print a short summary of the available
- options on \*(FCstdout\*(FR, then exit zero
+\*(FC\-W usage\*(FR%T{
+print a short summary of the available
+options on \*(FCstdout\*(FR, then exit zero.
+T}
\*(FC\-\^\-lint\*(FR
-\*(FC\-W lint\*(FR warn about constructs that are dubious
- or non-portable to other \*(AKs
+\*(FC\-W lint\*(FR%T{
+warn about constructs that are dubious
+or non-portable to other \*(AKs.
+T}
\*(FC\-\^\-lint\-old\*(FR
-\*(FC\-W lint\-old\*(FR warn about constructs that are not
- portable to the original version of
- Unix \*(AK
-.ig
-.\" This option is left undocumented, on purpose.
-\*(FC\-\^\-nostalgia\*(FR
-\*(FC\-W nostalgia\*(FR provide a moment of nostalgia for
- long time \*(AK users
-..
+\*(FC\-W lint\-old\*(FR%T{
+warn about constructs that are not
+portable to the original version of
+Unix \*(AK.
+T}
\*(FC\-\^\-posix\*(FR
-\*(FC\-W posix\*(FR disable common and GNU extensions.
- Enable \*(FIinterval expressions\*(FR in regular
- expression matching (see \fHRegular
- Expressions\fP, below)
+\*(FC\-W posix\*(FR%T{
+disable common and GNU extensions.
+Enable \*(FIinterval expressions\*(FR in regular
+expression matching (see \fHRegular
+Expressions\fP below).
+T}
\*(FC\-\^\-re\-interval\*(FR
-\*(FC\-W re\-interval\*(FR enable \*(FIinterval expressions\*(FR in regular
- expression matching (see \fHRegular
- Expressions\fP, below). Useful if
- \*(FC\-\^\-posix\*(FR is not specified
+\*(FC\-W re\-interval\*(FR%T{
+enable \*(FIinterval expressions\*(FR in regular
+expression matching (see \fHRegular
+Expressions\fP below). Useful if
+\*(FC\-\^\-posix\*(FR is not specified.
+T}
\*(FC\-\^\-source '\*(FItext\*(FC'\*(FR
-\*(FC\-W source '\*(FItext\*(FC'\*(FR use \*(FItext\*(FR as AWK program source code
+\*(FC\-W source '\*(FItext\*(FC'\*(FR%use \*(FItext\*(FR as AWK program source code.
\*(FC\-\^\-version\*(FR
-\*(FC\-W version\*(FR print version information on \*(FCstdout\fP
- and exit zero
+\*(FC\-W version\*(FR%T{
+print version information on \*(FCstdout\fP
+and exit zero.
+T}
+.TE
.sp .5
.fi
In compatibility mode,
@@ -246,7 +285,7 @@ any other options are flagged as illegal, but are otherwise ignored.
In normal operation, as long as program text has been supplied, unknown
options are passed on to the AWK program in
\*(FCARGV\*(FR
-for processing. This is most useful for running AWK
+for processing. This is most useful for running AWK
programs via the \*(FC#!\*(FR executable interpreter mechanism.\*(CB
.EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (\*(GK\f(HB)\*(FR\s0"
@@ -256,28 +295,43 @@ programs via the \*(FC#!\*(FR executable interpreter mechanism.\*(CB
.fi
\*(CDThe following options are specific to \*(MK.
.sp .5
-.nf
-\*(FC\-W dump\*(FR print an assembly listing of the program to
- \*(FCstdout\fP and exit zero
-\*(FC\-W exec \*(FIfile\*(FR read program text from \*(FIfile\fP. No other
- options are processed. Useful with \*(FC#!\fP
-\*(FC\-W interactive\*(FR unbuffer \*(FCstdout\fP and line buffer \*(FCstdin\fP.
- Lines are always records, ignoriing \*(FCRS\fP
-\*(FC\-W posix_space\*(FR make \*(FC\en\*(FR separate fields when \*(FCRS = "\^"\fP
-\*(FC\-W sprintf=\*(FInum\*(FR adjust the size of \*(MK's internal
- \*(FCsprintf\*(FR buffer
-\*(FC\-W version\*(FR print version and copyright information on
- \*(FCstdout\fP and limit information on \*(FCstderr\fP
- and exit zero
+.fi
+.TS
+expand;
+l lw(1.8i).
+\*(FC\-W dump\*(FR T{
+print an assembly listing of the program to
+\*(FCstdout\fP and exit zero.
+T}
+\*(FC\-W exec \*(FIfile\*(FR T{
+read program text from \*(FIfile\fP. No other
+options are processed. Useful with \*(FC#!\fP.
+T}
+\*(FC\-W interactive\*(FR T{
+unbuffer \*(FCstdout\fP and line buffer \*(FCstdin\fP.
+Lines are always records, ignoring \*(FCRS\fP
+T}
+\*(FC\-W posix_space\*(FR T{
+\*(FC\en\*(FR separates fields when \*(FCRS = "\^"\fP.
+T}
+\*(FC\-W sprintf=\*(FInum\*(FR T{
+adjust the size of \*(MK's internal
+\*(FCsprintf\*(FR buffer.
+T}
+\*(FC\-W version\*(FR T{
+print version and copyright on
+\*(FCstdout\fP and limit information on \*(FCstderr\fP
+and exit zero.
+T}
+.TE
.sp .5
.fi
The options may be abbreviated using just the first letter, e.g.,
\*(FC\-We\*(FR,
-\*(FC\-Wv\*(FR,
+\*(FC\-Wv\*(FR
and so on.\*(CB
.EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (\*(MK\f(HB)\*(FR\s0"
-
.\" --- Awk Program Execution
.ES
.fi
@@ -289,18 +343,18 @@ and optional function definitions.
\*(FCfunction \*(FIname\*(FC(\*(FIparameter list\*(FC) { \*(FIstatements\*(FC }\*(FR
.sp .5
\*(AK first reads the program source from the
-\*(FIprog-file\*(FR(s) if specified,
+\*(FIprog-file\*(FR(s), if specified,
\*(CBfrom arguments to \*(FC\-\^\-source\*(FR,\*(CD
or from the first non-option argument on the command line.
The program text is read as if all the \*(FIprog-file\*(FR(s)
\*(CBand command line
-source texts\*(CD had been concatenated together.
+source texts\*(CD had been concatenated.
.sp .5
AWK programs execute in the following order.
First, all variable assignments specified via the \*(FC\-v\fP
option are performed.
Next, \*(AK executes the code in the
-\*(FCBEGIN\fP rules(s) (if any), and then proceeds to read
+\*(FCBEGIN\fP rules(s), if any, and then proceeds to read
the files \*(FC1\fP through \*(FCARGC \- 1\fP in the \*(FCARGV\fP array.
(Adjusting \*(FCARGC\fP and \*(FCARGV\fP thus provides control over
the input files that will be processed.)
@@ -308,7 +362,7 @@ If there are no files named on the command line,
\*(AK reads the standard input.
.sp .5
If a command line argument has the form
-\*(FIvar\*(FC=\*(FIval\*(FR
+\*(FIvar\*(FC=\*(FIval\*(FR,
it is treated as a variable assignment. The variable
\*(FIvar\fP will be assigned the value \*(FIval\*(FR.
(This happens after any \*(FCBEGIN\fP rule(s) have been run.)
@@ -329,7 +383,7 @@ For each pattern that the record matches, the associated
The patterns are tested in the order they occur in the program.
.sp .5
Finally, after all the input is exhausted,
-\*(AK executes the code in the \*(FCEND\fP rule(s) (if any).
+\*(AK executes the code in the \*(FCEND\fP rule(s), if any.
.sp .5
If a program only has a \*(FCBEGIN\fP rule, no input files are processed.
If a program only has an \*(FCEND\fP rule, the input will be read.
@@ -344,7 +398,7 @@ If a program only has an \*(FCEND\fP rule, the input will be read.
.fi
\*(CDAWK is a line oriented language. The pattern comes first, and then the
action. Action statements are enclosed in \*(FC{\fP and \*(FC}\*(FR.
-Either the pattern may be missing, or the action may be missing, but
+Either the pattern or the action may be missing, but
not both. If the pattern is missing, the action will be
executed for every input record.
A missing action is equivalent to
@@ -360,19 +414,19 @@ a ``,'',
\*(FC{\*(FR,
\*(CB\*(FC?\*(FR,
\*(FC:\*(FR,\*(CD
-\*(FC&&\*(FR,
+\*(FC&&\*(FR
or
\*(FC||\*(FR
are automatically continued.
Lines ending in \*(FCdo\fP or \*(FCelse\fP
also have their statements automatically continued on the following line.
In other cases, a line can be continued by ending it with a ``\e'',
-in which case the newline will be ignored. However a ``\e'' after a
+in which case the newline will be ignored. However, a ``\e'' after a
\*(FC#\*(FR is not special.
.sp .5
Multiple statements may be put on one line by separating them with a ``;''.
This applies to both the statements within the action part of a
-pattern-action pair (the usual case),
+pattern-action pair (the usual case)
and to the pattern-action statements themselves.\*(CX
.EB "\s+2\f(HBLINES AND STATEMENTS\*(FR\s0"
@@ -422,12 +476,11 @@ _
.sp .5
.fi
\*(CRThe \*(FIr\*(FC{\*(FIn\*(FC,\*(FIm\*(FC}\*(FR notation is called an
-\*(FIinterval expression\fP. POSIX mandates it for AWK regexps, but
+\*(FIinterval expression\fP. POSIX mandates it for AWK regexps, but
most \*(AKs don't implement it. \*(CBUse \*(FC\-\^\-re\-interval\*(FR
or \*(FC\-\^\-posix\*(FR to enable
this feature in \*(GK.\*(CX
.EB "\s+2\f(HBREGULAR EXPRESSIONS\*(FR\s0"
-.ta .2i .78i 1i 1.2i 1.4i 1.7i
.BT
@@ -451,9 +504,6 @@ lp8 lp8 lp8 lp8.
.TE
.fi
.EB "\s+2\f(HBPOSIX CHARACTER CLASSES (\*(GK\f(HB)\*(FR\s0"
-.ta .2i .78i 1i 1.2i 1.4i 1.7i
-
-
.\" --- Records
.ES
@@ -481,8 +531,6 @@ a field separator, in addition to whatever value
when \*(FCRS = "\^"\fP.\*(CX
.EB \s+2\f(HBRECORDS\*(FR\s0
-
-
.\" --- Fields
.ES
.fi
@@ -513,19 +561,19 @@ overrides the use of \*(FCFIELDWIDTHS\*(FR,
and restores the default behavior.\*(CD
.sp .5
Each field in the input record may be referenced by its position,
-\*(FC$1\*(FR, \*(FC$2\*(FR, and so on.
+\*(FC$1\*(FR, \*(FC$2\*(FR and so on.
\*(FC$0\fP is the whole record.
-The value of a field may be assigned to as well.
+Fields may also be assigned new values.
.sp .5
The variable \*(FCNF\fP
is set to the total number of fields in the input record.
.sp .5
-References to non-existent fields (i.e. fields after \*(FC$NF\*(FR)
+References to non-existent fields (i.e., fields after \*(FC$NF\*(FR)
produce the null-string. However, assigning to a non-existent field
(e.g., \*(FC$(NF+2) = 5\*(FR) will increase the value of
\*(FCNF\*(FR, create any intervening fields with the null string as their value,
and cause the value of \*(FC$0\fP
-to be recomputed, with the fields being separated by the
+to be recomputed with the fields being separated by the
value of \*(FCOFS\*(FR.
References to negative numbered fields cause a fatal error.
Decreasing the value of \*(FCNF\fP causes the trailing fields to be lost
@@ -592,9 +640,16 @@ It does not combine with any other pattern expression.\*(CX
.fi
\*(CDWithin strings constants (\*(FC"..."\fP) and regexp
constants (\*(FC/.../\fP), escape sequences may be used to
-generate otherwise unprintable characters. This table lists
+generate otherwise unprintable characters. This table lists
the available escape sequences.
.sp .5
+.ig
+\*(CB\*(FCPROCINFO\fP T{
+elements of this array provide access to info
+about the running AWK program. See
+\*(AM for details.\*(CD
+T}
+..
.TS
center, tab(~);
lp8 lp8 lp8 lp8.
@@ -606,67 +661,107 @@ lp8 lp8 lp8 lp8.
\*(FC\e"\fP~double quote~\*(FC\e/\fP~forward slash\*(CX
.TE
.EB "\s+2\f(HBESCAPE SEQUENCES\*(FR\s0"
-.ta .2i .78i 1i 1.2i 1.4i 1.7i
.BT
.\" --- Variables
.ES
-.nf
-\*(FCARGC\fP number of command line arguments
-\*(CB\*(FCARGIND\fP index in \*(FCARGV\fP of current data file\*(CD
-\*(FCARGV\fP array of command line arguments. Indexed from
- 0 to \*(FCARGC\fP \- 1. Dynamically changing the
- contents of \*(FCARGV\fP can control the files used
- for data
-\*(FCCONVFMT\fP conversion format for numbers, default value
- is \*(FC"%.6g"\*(FR
-\*(FCENVIRON\fP array containing the the current environment.
- The array is indexed by the environment
- variables, each element being the value of
- that variable
-\*(CB\*(FCERRNO\fP contains a string describing the error when a
- redirection or read for \*(FCgetline\*(FR fails, or if
- \*(FCclose()\*(FR fails
-\*(CB\*(FCFIELDWIDTHS\fP white-space separated list of fieldwidths. Used
- to parse the input into fields of fixed width,
- instead of the value of \*(FCFS\fP\*(CD
-\*(FCFILENAME\fP name of the current input file. If no files given
- on the command line, \*(FCFILENAME\fP is ``\-''.
- \*(FCFILENAME\fP is undefined inside the \*(FCBEGIN\fP rule
- (unless set by \*(FCgetline\fP)
-\*(FCFNR\fP number of the input record in current input file
-\*(FCFS\fP input field separator, a space by default.
- See \fHFields\fP, above
-\*(CB\*(FCIGNORECASE\fP if non-zero, all regular expression and string
- operations ignore case. \*(CRIn versions of \*(GK
- prior to 3.0, \*(FCIGNORECASE\fP only affected
- regular expression operations and \*(FCindex()\*(FR\*(CD
-\*(FCNF\fP number of fields in the current input record
-\*(FCNR\fP total number of input records seen so far
-\*(FCOFMT\fP output format for numbers, \*(FC"%.6g"\*(FR, by default.
- \*(CROld versions of \*(AK also used this for number
- to string conversion instead of \*(FCCONVFMT\fP\*(CD
-\*(FCOFS\fP output field separator, a space by default
-\*(FCORS\fP output record separator, a newline by default
-.ig
-\*(CB\*(FCPROCINFO\fP elements of this array provide access to info
- about the running AWK program. See
- \*(AM for details\*(CD
-..
-\*(FCRS\fP input record separator, a newline by default.
- See \fHRecords\fP, above
-\*(CB\*(FCRT\fP record terminator. \*(GK sets \*(FCRT\fP to the input
- text that matched the character or regular
- expression specified by \*(FCRS\*(FR\*(CD
-\*(FCRSTART\fP index of the first character matched by
- \*(FCmatch()\*(FR; 0 if no match
-\*(FCRLENGTH\fP length of the string matched by \*(FCmatch()\*(FR;
- \-1 if no match
-\*(FCSUBSEP\fP character(s) used to separate multiple subscripts
- in array elements, by default \*(FC"\e034"\*(FR. See
- \fHArrays\fP, below\*(CX
+.fi
+.TS
+expand;
+l lw(2i).
+\*(FCARGC\fP T{
+number of command line arguments.
+T}
+\*(CB\*(FCARGIND\fP T{
+index in \*(FCARGV\fP of current data file.\*(CD
+T}
+\*(FCARGV\fP T{
+array of command line arguments. Indexed from
+0 to \*(FCARGC\fP \- 1. Dynamically changing the
+contents of \*(FCARGV\fP can control the files used
+for data.
+T}
+\*(FCCONVFMT\fP T{
+conversion format for numbers, default value
+is \*(FC"%.6g"\*(FR.
+T}
+\*(FCENVIRON\fP T{
+array containing the the current environment.
+The array is indexed by the environment
+variables, each element being the value of
+that variable.
+T}
+\*(CB\*(FCERRNO\fP T{
+contains a string describing the error when a
+redirection or read for \*(FCgetline\*(FR fails, or if
+\*(FCclose()\*(FR fails.
+T}
+\*(FCFIELDWIDTHS\fP T{
+white-space separated list of fieldwidths. Used
+to parse the input into fields of fixed width,
+instead of the value of \*(FCFS\fP.\*(CD
+T}
+\*(FCFILENAME\fP T{
+name of the current input file. If no files given
+on the command line, \*(FCFILENAME\fP is ``\-''.
+\*(FCFILENAME\fP is undefined inside the \*(FCBEGIN\fP rule
+(unless set by \*(FCgetline\fP).
+T}
+\*(FCFNR\fP T{
+number of the input record in current input file.
+T}
+\*(FCFS\fP T{
+input field separator, a space by default
+(see \fHFields\fP above).
+T}
+\*(CB\*(FCIGNORECASE\fP T{
+if non-zero, all regular expression and string
+operations ignore case. \*(CRIn versions of \*(GK
+prior to 3.0, \*(FCIGNORECASE\fP only affected
+regular expression operations and \*(FCindex()\*(FR.\*(CD
+T}
+\*(FCNF\fP T{
+number of fields in the current input record.
+T}
+\*(FCNR\fP T{
+total number of input records seen so far.
+T}
+\*(FCOFMT\fP T{
+output format for numbers, \*(FC"%.6g"\*(FR, by default.
+\*(CROld versions of \*(AK also used this for number
+to string conversion instead of \*(FCCONVFMT\fP.\*(CD
+T}
+\*(FCOFS\fP T{
+output field separator, a space by default.
+T}
+\*(FCORS\fP T{
+output record separator, a newline by default.
+T}
+\*(FCRS\fP T{
+input record separator, a newline by default
+(see \fHRecords\fP above).
+T}
+\*(CB\*(FCRT\fP T{
+record terminator. \*(GK sets \*(FCRT\fP to the input
+text that matched the character or regular
+expression specified by \*(FCRS\*(FR.\*(CD
+T}
+\*(FCRSTART\fP T{
+index of the first character matched by
+\*(FCmatch()\*(FR; 0 if no match.
+T}
+\*(FCRLENGTH\fP T{
+length of the string matched by \*(FCmatch()\*(FR;
+\-1 if no match.
+T}
+\*(FCSUBSEP\fP T{
+character(s) used to separate multiple subscripts
+in array elements, by default \*(FC"\e034"\*(FR. (see
+\fHArrays\fP below).\*(CX
+T}
+.TE
.EB \s+2\f(HBVARIABLES\*(FR\s0
.BT
@@ -674,14 +769,14 @@ lp8 lp8 lp8 lp8.
.\" --- Arrays
.ES
.fi
-\*(CDArrays are subscripted with an expression between square brackets
+\*(CDAn arrays subscript is an expression between square brackets
(\*(FC[ \*(FRand \*(FC]\*(FR).
-If the expression is an expression list
-\*(FC(\*(FIexpr\*(FC, \*(FIexpr \*(FC...)\*(FR
-then the array subscript is a string consisting of the
+If the expression is a list
+\*(FC(\*(FIexpr\*(FC, \*(FIexpr \*(FC...)\*(FR,
+then the subscript is a string consisting of the
concatenation of the (string) value of each expression,
separated by the value of the \*(FCSUBSEP\fP variable.
-This facility simulates multiply dimensioned
+This simulates multi-dimensional
arrays. For example:
.nf
.sp .5
@@ -689,14 +784,14 @@ arrays. For example:
x[i, j, k] = "hello, world\en"\*(FR
.sp .5
.fi
-assigns the string \*(FC"hello, world\en"\*(FR to the element of the array
+assigns \*(FC"hello, world\en"\*(FR to the element of the array
\*(FCx\fP
-which is indexed by the string \*(FC"A\e034B\e034C"\*(FR. All arrays in AWK
-are associative, i.e. indexed by string values.
+indexed by the string \*(FC"A\e034B\e034C"\*(FR. All arrays in AWK
+are associative, i.e., indexed by string values.
.sp .5
-The special operator \*(FCin\fP may be used in an \*(FCif\fP
-or \*(FCwhile\fP statement to see if an array has an index consisting
-of a particular value.
+Use the special operator \*(FCin\fP in an \*(FCif\fP
+or \*(FCwhile\fP statement to see if a particular value is
+an array index.
.sp .5
.nf
\*(FCif (val in array)
@@ -706,24 +801,23 @@ of a particular value.
If the array has multiple subscripts, use
\*(FC(i, j) in array\*(FR.
.sp .5
-The \*(FCin\fP construct may also be used in a \*(FCfor\fP
+Use the \*(FCin\fP construct in a \*(FCfor\fP
loop to iterate over all the elements of an array.
.sp .5
-An element may be deleted from an array using the
-\*(FCdelete\fP statement.
-\*(CLThe \*(FCdelete\fP
-statement can also delete the entire contents of an array,
-just by specifying the array name without a subscript.\*(CX
+Use the \*(FCdelete\fP statement to delete an
+element from an array.
+\*(CLSpecifying just the array name without a subscript in
+the \*(FCdelete\fP
+statement deletes the entire contents of an array.\*(CX
.EB \s+2\f(HBARRAYS\*(FR\s0
-
.\" --- Expressions
.ES
.fi
-\*(CDExpressions are used as patterns, for controlling conditional
+\*(CDExpressions are used as patterns, for controlling conditional action
statements, and to produce parameter values when calling functions.
Expressions may also be used as simple statements,
-particularly if they have side-effects, such as assignment.
+particularly if they have side-effects such as assignment.
Expressions mix \*(FIoperands\fP and \*(FIoperators\fP. Operands are
constants, fields, variables, array elements, and the return
values from function calls (both built-in and user-defined).
@@ -741,10 +835,16 @@ functions, mean \*(FC$0 ~ /\*(FIpat\*(FC/\*(FR.
.sp .5
The AWK operators, in order of decreasing precedence, are
.sp .5
-.nf
+.fi
+.TS
+expand;
+l lw(1.8i).
\*(FC(\&...)\*(FR grouping
-\*(FC$\fP field reference
-\*(FC++ \-\^\-\fP increment and decrement, both prefix and postfix
+\*(FC$\fP field reference
+\*(FC++ \-\^\-\fP T{
+increment and decrement,
+prefix and postfix
+T}
\*(FC^\fP \*(CL\*(FC**\*(FR\*(CD exponentiation
\*(FC+ \- !\fP unary plus, unary minus, and logical negation
\*(FC* / %\fP multiplication, division, and modulus
@@ -754,12 +854,16 @@ The AWK operators, in order of decreasing precedence, are
\*(FC<= >=\fP less than or equal, greater than or equal
\*(FC!= ==\fP not equal, equal
\*(FC~ !~\fP regular expression match, negated match
-\*(FCin\fP array membership
-\*(FC&&\fP logical AND, short circuit
-\*(FC||\fP logical OR, short circuit
-\*(FC?\^:\fP in-line conditional expression
+\*(FCin\fP array membership
+\*(FC&&\fP logical AND, short circuit
+\*(FC||\fP logical OR, short circuit
+\*(FC?\^:\fP in-line conditional expression
+.T&
+l s
+l lw(1.8i).
\*(FC=\0+=\0\-=\0*=\0/=\0%=\0^=\0\*(CL**=\*(CD\fP
- assignment operators\*(CX
+ assignment operators\*(CX
+.TE
.EB \s+2\f(HBEXPRESSIONS\*(FR\s0
@@ -768,7 +872,7 @@ The AWK operators, in order of decreasing precedence, are
.\" --- Conversions and Comparisons
.ES
.fi
-\*(CDVariables and fields may be (floating point) numbers, or strings, or both.
+\*(CDVariables and fields may be (floating point) numbers, strings or both.
Context determines how the value of a variable is interpreted. If used in
a numeric expression, it will be treated as a number, if used as a string
it will be treated as a string.
@@ -788,15 +892,15 @@ Comparisons are performed as follows:
If two variables are numeric, they are compared numerically.
If one value is numeric and the other has a string value that is a
``numeric string,'' then comparisons are also done numerically.
-Otherwise, the numeric value is converted to a string and a string
+Otherwise, the numeric value is converted to a string, and a string
comparison is performed.
Two strings are compared, of course, as strings.
\*(CRAccording to the POSIX standard, even if two strings are
-numeric strings, a numeric comparison is performed. However, this is
+numeric strings, a numeric comparison is performed. However, this is
clearly incorrect, and none of the three free \*(AK\*(FRs do this.\*(CD
.sp .5
Note that string constants, such as \*(FC"57"\fP, are \*(FInot\fP
-numeric strings, they are string constants. The idea of ``numeric string''
+numeric strings, they are string constants. The idea of ``numeric string''
only applies to fields, \*(FCgetline\fP input,
\*(FCFILENAME\*(FR, \*(FCARGV\fP elements, \*(FCENVIRON\fP
elements and the elements of an array created by
@@ -830,41 +934,64 @@ construction.\*(CB
.EB "\s+2\f(HBLOCALIZATION\*(FR\s0"
..
+.ps +2
+.ce 1
+\*(CD\fHISBN: 0-916151-97-2\*(FR
+.ps -2
+
.BT
.\" --- Input Control
.ES
-.nf
-\*(CD\*(FCclose(\*(FIfile\*(FC)\*(FR close input file or pipe
-\*(FCgetline\fP set \*(FC$0\fP from next input record;
- set \*(FCNF\*(FR, \*(FCNR\*(FR, \*(FCFNR\*(FR
-\*(FCgetline < \*(FIfile\*(FR set \*(FC$0\fP from next record of \*(FIfile\*(FR; set \*(FCNF\*(FR
-\*(FCgetline \*(FIv\*(FR set \*(FIv\fP from next input record;
- set \*(FCNR\*(FR, \*(FCFNR\*(FR
-\*(FCgetline \*(FIv \*(FC< \*(FIfile\*(FR set \*(FIv\fP from next record of \*(FIfile\*(FR
-\*(FIcmd \*(FC| getline\*(FR pipe into \*(FCgetline\*(FR; set \*(FC$0\*(FR, \*(FCNF\*(FR
-\*(FIcmd \*(FC| getline \*(FIv\*(FR pipe into \*(FCgetline\*(FR; set \*(FIv\*(FR
-\*(FCnext\fP stop processing the current input
- record. Read next input record and
- start over with the first pattern in the
- program. Upon end of the input data,
- execute any \*(FCEND\fP rule(s)
-\*(CL\*(FCnextfile\fP stop processing the current input file.
- The next input record comes from the
- next input file. \*(FCFILENAME\fP \*(CBand
- \*(FCARGIND\fP\*(CL are updated, \*(FCFNR\fP is reset to 1,
- and processing starts over with the first
- pattern in the AWK program. Upon end
- of input data, execute any \*(FCEND\fP rule(s).
- \*(CREarlier versions of \*(GK used
- \*(FCnext file\*(FR, as two words. This
- generates a warning message and will
- eventually be removed. \*(CR\*(MK does not
- currently support \*(FCnextfile\*(FR\*(CD
+.fi
+.TS
+expand;
+l lw(1.8i).
+\*(CD\*(FCclose(\*(FIfile\*(FC)\*(FR close input file or pipe.
+\*(FCgetline\fP T{
+set \*(FC$0\fP from next input record;
+set \*(FCNF\*(FR, \*(FCNR\*(FR, \*(FCFNR\*(FR.
+T}
+\*(FCgetline < \*(FIfile\*(FR set \*(FC$0\fP from next record of \*(FIfile\*(FR; set \*(FCNF\*(FR.
+\*(FCgetline \*(FIv\*(FR T{
+set \*(FIv\fP from next input record;
+set \*(FCNR\*(FR, \*(FCFNR\*(FR.
+T}
+\*(FCgetline \*(FIv \*(FC< \*(FIfile\*(FR set \*(FIv\fP from next record of \*(FIfile\*(FR.
+\*(FIcmd \*(FC| getline\*(FR pipe into \*(FCgetline\*(FR; set \*(FC$0\*(FR, \*(FCNF\*(FR.
+\*(FIcmd \*(FC| getline \*(FIv\*(FR pipe into \*(FCgetline\*(FR; set \*(FIv\*(FR.
+.TE
+.fi
+.in +.2i
+.ti -.2i
+\*(FCnext\fP
+.br
+stop processing the current input
+record. Read next input record and
+start over with the first pattern in the
+program. Upon end of the input data,
+execute any \*(FCEND\fP rule(s).
+.br
+.ti -.2i
+\*(CL\*(FCnextfile\fP
+.br
+stop processing the current input file.
+The next input record comes from the
+next input file. \*(FCFILENAME\fP \*(CBand
+\*(FCARGIND\fP\*(CL are updated, \*(FCFNR\fP is reset to 1,
+and processing starts over with the first
+pattern in the AWK program. Upon end
+of input data, execute any \*(FCEND\fP rule(s).
+\*(CREarlier versions of \*(GK used
+\*(FCnext file\*(FR, as two words. This
+generates a warning message and will
+eventually be removed. \*(CR\*(MK does not
+currently support \*(FCnextfile\*(FR.\*(CD
+.in -.2i
.sp .5
.fi
-The \*(FCgetline\*(FR command returns 0 on end of file, and \-1 on an
+\*(FCgetline\*(FR returns 0 on end of file, and \-1 on an
error.\*(CX
.EB "\s+2\f(HBINPUT CONTROL\*(FR\s0"
@@ -875,7 +1002,7 @@ error.\*(CX
.ti -.2i
\*(CD\*(FCclose(\*(FIfile\*(FC)\*(FR
.br
-close output file or pipe
+close output file or pipe.
.ti -.2i
\*(CL\*(FCfflush(\*(FR[\*(FIfile\^\*(FR]\*(FC)\*(FR
.br
@@ -883,28 +1010,28 @@ flush any buffers associated
with the open output file or pipe \*(FIfile\*(FR.\*(CD
\*(CBIf \*(FIfile\fP is missing, then standard output is flushed.
If \*(FIfile\fP is the null string, then all open output files and pipes
-are flushed \*(CR(not \*(NK)\*(CD
+are flushed \*(CR(not \*(NK)\*(CD.
.ti -.2i
\*(FCprint\fP
.br
-print the current record. The output record is terminated
-with the value of \*(FCORS\fP
+print the current record. The output record is terminated
+with the value of \*(FCORS\fP.
.ti -.2i
\*(FCprint \*(FIexpr-list\*(FR
.br
-print expressions. Each expression is separated
-by the value of \*(FCOFS\fP. The output record is
-terminated with the value of \*(FCORS\fP
+print expressions. Each expression is separated
+by the value of \*(FCOFS\fP. The output record is
+terminated with the value of \*(FCORS\fP.
.ti -.2i
\*(FCprintf \*(FIfmt\*(FC, \*(FIexpr-list\*(FR
.br
-format and print (see \fHPrintf Formats\fP, below)
+format and print (see \fHPrintf Formats\fP below).
.ti -.2i
\*(FCsystem(\*(FIcmd\*(FC)\*(FR
.br
execute the command \*(FIcmd\*(FR,
and return the exit status
-\*(CR(may not be available on non-POSIX systems)\*(CD
+\*(CR(may not be available on non-POSIX systems)\*(CD.
.sp .5
.in -.2i
I/O redirections may be used with both \*(FCprint\fP and \*(FCprintf\fP.
@@ -948,49 +1075,75 @@ accept the following conversion specification formats:
\*(FC%g\fP use \*(FC%e\fP or \*(FC%f\fP, whichever is shorter, with
nonsignificant zeros suppressed
\*(FC%G\fP like \*(FC%g\fP, but use \*(FC%E\fP instead of \*(FC%e\*(FR
-\*(FC%o\fP an unsigned octal number (the integer part)
+\*(FC%o\fP an unsigned octal integer
\*(FC%s\fP a character string
-\*(FC%x\fP an unsigned hexadecimal number (integer part)
-\*(FC%X\fP like \*(FC%x\fP, but use \*(FCABCDEF\fP instead of \*(FCabcdef\*(FR
-\*(FC%%\fP A single \*(FC%\fP character; no argument is converted
+\*(FC%x\fP an unsigned hexadecimal integer
+\*(FC%X\fP like \*(FC%x\fP, but use \*(FCABCDEF\fP for 10\(en15
+\*(FC%%\fP A literal \*(FC%\fP; no argument is converted
.sp .5
.fi
Optional, additional parameters may lie between the \*(FC%\fP
and the control letter:
.sp .5
-.nf
-\*(FC\-\fP left-justify the expression within its field
-\*(FIspace\fP for numeric conversions, prefix positive values
- with a space, and negative values with a
- minus sign
-\*(FC+\fP used before the \*(FIwidth\fP modifier means to always
- supply a sign for numeric conversions, even if
- the data to be formatted is positive. The \*(FC+\fP
- overrides the space modifier
-\*(FC#\fP use an ``alternate form'' for some control letters.
- For \*(FC%o\*(FR, supply a leading zero.
- For \*(FC%x\*(FR, and \*(FC%X\*(FR, supply a leading \*(FC0x\*(FR or \*(FC0X\*(FR for a
- nonzero result.
- For \*(FC%e\*(FR, \*(FC%E\*(FR, and \*(FC%f\*(FR, the result will always
- contain a decimal point.
- For \*(FC%g\*(FR, and \*(FC%G\*(FR, trailing zeros are not removed
-\*(FC0\fP a leading zero acts as a flag, indicating output
- should be padded with zeroes instead of spaces.
- This applies even to non-numeric output formats.
- Only has an effect when the field width is wider
- than the value to be printed
-\*(FIwidth\fP pad the field to this width. The field is normally
- padded with spaces. If the \*(FC0\fP flag has been used,
- pad with zeroes
-\*(FC\&.\*(FIprec\*(FR specifies the precision to use when printing.
- For the \*(FC%e\*(FR, \*(FC%E\*(FR, and \*(FC%f\*(FR formats, the number of
- digits to print to the right of the decimal point.
- For the \*(FC%g\*(FR and \*(FC%G\fP formats, the maximum
- number of significant digits.
- For the \*(FC%d\*(FR, \*(FC%o\*(FR, \*(FC%i\*(FR, \*(FC%u\*(FR, \*(FC%x\*(FR, and \*(FC%X\fP formats, the
- minimum number of digits to print.
- For the \*(FC%s\fP format, the maximum number of
- characters to print
+.TS
+expand;
+l lw(2.2i).
+\*(FC\-\fP T{
+left-justify the expression within its field.
+T}
+\*(FIspace\fP T{
+for numeric conversions, prefix positive values
+with a space and negative values with a
+minus sign.
+T}
+\*(FC+\fP T{
+used before the \*(FIwidth\fP modifier means to always
+supply a sign for numeric conversions, even if
+the data to be formatted is positive. The \*(FC+\fP
+overrides the space modifier.
+T}
+\*(FC#\fP T{
+use an ``alternate form'' for some control letters.
+T}
+ \*(FC%o\*(FR T{
+supply a leading zero.
+T}
+ \*(FC%x\*(FR, \*(FC%X\*(FR T{
+supply a leading \*(FC0x\*(FR or \*(FC0X\*(FR for a nonzero result.
+T}
+ \*(FC%e\*(FR, \*(FC%E\*(FR, \*(FC%f\*(FR T{
+the result always has a decimal point.
+T}
+ \*(FC%g\*(FR, \*(FC%G\*(FR T{
+trailing zeros are not removed.
+T}
+\*(FC0\fP T{
+a leading zero acts as a flag, indicating output
+should be padded with zeroes instead of spaces.
+This applies even to non-numeric output formats.
+Only has an effect when the field width is wider
+than the value to be printed.
+T}
+\*(FIwidth\fP T{
+pad the field to this width. The field is normally
+padded with spaces. If the \*(FC0\fP flag has been used,
+pad with zeroes.
+The meaning of the \*(FIwidth\*(FR varies by control letter:
+T}
+ \*(FC%d\*(FR, \*(FC%o\*(FR, \*(FC%i\*(FR,
+ \*(FC%u\*(FR, \*(FC%x\*(FR, \*(FC%X\fP T{
+the minimum number of digits to print.
+T}
+ \*(FC%e\*(FR, \*(FC%E\*(FR, \*(FC%f\*(FR T{
+the number of digits to print to the right of the decimal point.
+T}
+ \*(FC%g\*(FR, \*(FC%G\fP T{
+the maximum number of significant digits.
+T}
+ \*(FC%s\fP T{
+the maximum number of characters to print.
+T}
+.TE
.sp .5
.fi
The dynamic \*(FIwidth\fP and \*(FIprec\fP capabilities of the ANSI C
@@ -1008,44 +1161,60 @@ the argument list to \*(FCprintf\fP or \*(FCsprintf()\*(FR.\*(CX
.ES
.fi
\*(CDWhen doing I/O redirection from either \*(FCprint\fP
-or \*(FCprintf\fP into a file, or via \*(FCgetline\fP
+or \*(FCprintf\fP into a file or via \*(FCgetline\fP
from a file, all three implementations of \*(FCawk\fP
-recognize certain special filenames internally. These filenames
+recognize certain special filenames internally. These filenames
allow access to open file descriptors inherited from the
parent process (usually the shell).
-These file names may also be used on the command line to name data files.
+These filenames may also be used on the command line to name data files.
The filenames are:
.sp .5
-.nf
-\*(FC"-"\fP standard input
+.TS
+expand;
+l lw(2i).
+\*(FC"\-"\fP standard input
\*(FC/dev/stdin\fP standard input \*(CR(not \*(MK)\*(CD
\*(FC/dev/stdout\fP standard output
\*(FC/dev/stderr\fP standard error output
+.TE
.sp .5
.fi
\*(CBThe following names are specific to \*(GK.
.sp .5
-.nf
-\*(FC/dev/fd/\^\*(FIn\*(FR file associated with the open file descriptor \*(FIn\*(FR
+.TS
+expand;
+l lw(2i).
+\*(FC/dev/fd/\^\*(FIn\*(FR T{
+file associated with the open file descriptor \*(FIn\*(FR
+T}
+.TE
.sp .5
.fi
Other special filenames provide access to information about the running
\*(FCgawk\fP process.
-The filenames are:\*(FR
+Reading from these files returns a single record.
+The filenames and what they return are:\*(FR
.sp .5
+.TS
+expand;
+l lw(2i).
+\*(FC/dev/pid\fP process ID of current process
+\*(FC/dev/ppid\fP parent process ID of current process
+\*(FC/dev/pgrpid\fP process group ID of current process
+\*(FC/dev/user\fP T{
.nf
-\*(FC/dev/pid\fP returns process ID of current process
-\*(FC/dev/ppid\fP returns parent process ID of current process
-\*(FC/dev/pgrpid\fP returns process group ID of current process
-\*(FC/dev/user\fP returns a single newline-terminated record.
- The fields are separated with spaces.
- \*(FC$1\fP is the return value of \*(FIgetuid\*(FR(2),
- \*(FC$2\fP is the return value of \*(FIgeteuid\*(FR(2),
- \*(FC$3\fP is the return value of \*(FIgetgid\*(FR(2) , and
- \*(FC$4\fP is the return value of \*(FIgetegid\*(FR(2).
- Any additional fields are the group IDs returned
- by \*(FIgetgroups\*(FR(2). Multiple groups may not be
- supported on all systems
+a single newline-terminated record.
+The fields are separated with spaces.
+\*(FC$1\fP is the return value of \*(FIgetuid\*(FR(2),
+\*(FC$2\fP is the return value of \*(FIgeteuid\*(FR(2),
+\*(FC$3\fP is the return value of \*(FIgetgid\*(FR(2) , and
+\*(FC$4\fP is the return value of \*(FIgetegid\*(FR(2).
+.fi
+Any additional fields are the group IDs returned
+by \*(FIgetgroups\*(FR(2). Multiple groups may not be
+supported on all systems.
+T}
+.TE
.sp .5
.fi
.ig
@@ -1063,19 +1232,25 @@ Be aware that you will have to change your programs.\*(CL
.\" --- Builtin Numeric Functions
.ES
-.nf
-\*(CD\*(FCatan2(\*(FIy\*(FC, \*(FIx\*(FC)\*(FR returns the arctangent of \*(FIy/x\fP in radians
-\*(FCcos(\*(FIexpr\*(FC)\*(FR the cosine of \*(FIexpr\fP, which is in radians
-\*(FCexp(\*(FIexpr\*(FC)\*(FR the exponential function (\*(FIe \*(FC^ \*(FIx\*(FR)
-\*(FCint(\*(FIexpr\*(FC)\*(FR truncates to integer
-\*(FClog(\*(FIexpr\*(FC)\*(FR the natural logarithm function (base \*(FIe\^\*(FR)
-\*(FCrand()\fP returns a random number between 0 and 1
-\*(FCsin(\*(FIexpr\*(FC)\*(FR the sine of \*(FIexpr\fP, which is in radians
-\*(FCsqrt(\*(FIexpr\*(FC)\*(FR the square root function
-\&\*(FCsrand(\*(FR[\*(FIexpr\^\*(FR]\*(FC)\*(FR uses \*(FIexpr\fP as a new seed for the random number
- generator. If no \*(FIexpr\fP, the time of day is used.
- Returns previous seed for the random number
- generator\*(CX
+.fi
+.TS
+expand;
+l lw(2i).
+\*(CD\*(FCatan2(\*(FIy\*(FC, \*(FIx\*(FC)\*(FR the arctangent of \*(FIy/x\fP in radians.
+\*(FCcos(\*(FIexpr\*(FC)\*(FR the cosine of \*(FIexpr\fP, which is in radians.
+\*(FCexp(\*(FIexpr\*(FC)\*(FR the exponential function (\*(FIe \*(FC^ \*(FIx\*(FR).
+\*(FCint(\*(FIexpr\*(FC)\*(FR truncates to integer.
+\*(FClog(\*(FIexpr\*(FC)\*(FR the natural logarithm function (base \*(FIe\^\*(FR).
+\*(FCrand()\fP a random number between 0 and 1.
+\*(FCsin(\*(FIexpr\*(FC)\*(FR the sine of \*(FIexpr\fP, which is in radians.
+\*(FCsqrt(\*(FIexpr\*(FC)\*(FR the square root function.
+\&\*(FCsrand(\*(FR[\*(FIexpr\^\*(FR]\*(FC)\*(FR T{
+uses \*(FIexpr\fP as a new seed for the random number
+generator. If no \*(FIexpr\fP, the time of day is used.
+Returns previous seed for the random number
+generator.\*(CX
+T}
+.TE
.EB "\s+2\f(HBNUMERIC FUNCTIONS\*(FR\s0"
@@ -1090,86 +1265,87 @@ Be aware that you will have to change your programs.\*(CL
\*(CB\*(FCgensub(\*(FIr\*(FC, \*(FIs\*(FC, \*(FIh \*(FR[\*(FC, \*(FIt\*(FR]\*(FC)\*(FR
.br
search the target string
-\*(FIt\fP for matches of the regular expression \*(FIr\*(FR. If
+\*(FIt\fP for matches of the regular expression \*(FIr\*(FR. If
\*(FIh\fP is a string beginning with \*(FCg\fP or \*(FCG\*(FR,
-replace all matches of \*(FIr\fP with \*(FIs\*(FR. Otherwise, \*(FIh\fP
-is a number indicating which match of \*(FIr\fP to replace. If no
-\*(FIt\fP is supplied, \*(FC$0\fP is used instead. Within the
+replace all matches of \*(FIr\fP with \*(FIs\*(FR. Otherwise, \*(FIh\fP
+is a number indicating which match of \*(FIr\fP to replace. If no
+\*(FIt\fP is supplied, \*(FC$0\fP is used instead. Within the
replacement text \*(FIs\*(FR, the sequence \*(FC\e\*(FIn\*(FR,
where \*(FIn\fP is a digit from 1 to 9, may be used to indicate just
-the text that matched the \*(FIn\*(FR'th parenthesized subexpression.
+the text that matched the \*(FIn\*(FRth parenthesized subexpression.
The sequence \*(FC\e0\fP represents the entire matched text, as does
-the character \*(FC&\*(FR. Unlike \*(FCsub()\fP and \*(FCgsub()\*(FR,
+the character \*(FC&\*(FR. Unlike \*(FCsub()\fP and \*(FCgsub()\*(FR,
the modified string is returned as the result of the function,
-and the original target string is \*(FInot\fP changed\*(CD
+and the original target string is \*(FInot\fP changed.\*(CD
.ti -.2i
\*(FCgsub(\*(FIr\*(FC, \*(FIs \*(FR[\*(FC, \*(FIt\*(FR]\*(FC)\*(FR
.br
for each substring matching the
regular expression \*(FIr\fP in the string \*(FIt\*(FR, substitute the
-string \*(FIs\*(FR, and return the number of substitutions. If
-\*(FIt\fP is not supplied, use \*(FC$0\*(FR. An \*(FC&\fP in the
+string \*(FIs\*(FR, and return the number of substitutions. If
+\*(FIt\fP is not supplied, use \*(FC$0\*(FR. An \*(FC&\fP in the
replacement text is replaced with the text that was actually matched.
-Use \*(FC\e&\fP to get a literal \*(FC&\*(FR. See \*(AM
+Use \*(FC\e&\fP to get a literal \*(FC&\*(FR. See \*(AM
for a fuller discussion of the rules for \*(FC&\*(FR's and backslashes
-in the replacement text of \*(CB\*(FCgensub()\*(FR,\*(CD \*(FCsub()\*(FR,
+in the replacement text of \*(CB\*(FCgensub()\*(FR,\*(CD \*(FCsub()\*(FR
and \*(FCgsub()\*(FR
.ti -.2i
\*(FCindex(\*(FIs\*(FC, \*(FIt\*(FC)\*(FR
.br
returns the index of the string
-\*(FIt\fP in the string \*(FIs\*(FR, or 0 if \*(FIt\fP is not present
+\*(FIt\fP in the string \*(FIs\*(FR, or 0 if \*(FIt\fP is not present.
.ti -.2i
\*(FClength(\*(FR[\*(FIs\*(FR]\*(FC)\*(FR
.br
returns the length of the string
-\*(FIs\*(FR, or the length of \*(FC$0\fP if \*(FIs\fP is not supplied
+\*(FIs\*(FR, or the length of \*(FC$0\fP if \*(FIs\fP is not supplied.
.ti -.2i
\*(FCmatch(\*(FIs\*(FC, \*(FIr\*(FC)\*(FR
.br
returns the position in
\*(FIs\fP where the regular expression \*(FIr\fP occurs, or 0 if
-\*(FIr\fP is not present, and sets the values of \*(FCRSTART\fP
-and \*(FCRLENGTH\*(FR
+\*(FIr\fP is not present, and sets the values of variables
+\*(FCRSTART\fP
+and \*(FCRLENGTH\*(FR.
.ti -.2i
\*(FCsplit(\*(FIs\*(FC, \*(FIa \*(FR[\*(FC, \*(FIr\*(FR]\*(FC)\*(FR
.br
splits the string
-\*(FIs\fP into the array \*(FIa\fP on the regular expression \*(FIr\*(FR,
+\*(FIs\fP into the array \*(FIa\fP using the regular expression \*(FIr\*(FR,
and returns the number of fields. If \*(FIr\fP is omitted, \*(FCFS\fP
-is used instead. The array \*(FIa\fP is cleared first.
+is used instead. The array \*(FIa\fP is cleared first.
Splitting behaves identically to field splitting.
-See \fHFields\fP, above
+(See \fHFields\fP, above.)
.ti -.2i
\*(FCsprintf(\*(FIfmt\*(FC, \*(FIexpr-list\*(FC)\*(FR
.br
prints \*(FIexpr-list\fP
-according to \*(FIfmt\*(FR, and returns the resulting string
+according to \*(FIfmt\*(FR, and returns the resulting string.
.ti -.2i
\*(FCsub(\*(FIr\*(FC, \*(FIs \*(FR[\*(FC, \*(FIt\*(FR]\*(FC)\*(FR
.br
just like
-\*(FCgsub()\*(FR, but only the first matching substring is replaced
+\*(FCgsub()\*(FR, but only the first matching substring is replaced.
.ti -.2i
\*(FCsubstr(\*(FIs\*(FC, \*(FIi \*(FR[\*(FC, \*(FIn\*(FR]\*(FC)\*(FR
.br
returns the at most
\*(FIn\*(FR-character substring of \*(FIs\fP starting at \*(FIi\*(FR.
-If \*(FIn\fP is omitted, the rest of \*(FIs\fP is used
+If \*(FIn\fP is omitted, the rest of \*(FIs\fP is used.
.ti -.2i
\*(FCtolower(\*(FIstr\*(FC)\*(FR
.br
returns a copy of the string \*(FIstr\*(FR,
with all the upper-case characters in \*(FIstr\fP translated to their
-corresponding lower-case counterparts. Non-alphabetic characters are
-left unchanged
+corresponding lower-case counterparts. Non-alphabetic characters are
+left unchanged.
.ti -.2i
\*(FCtoupper(\*(FIstr\*(FC)\*(FR
.br
returns a copy of the string \*(FIstr\*(FR,
with all the lower-case characters in \*(FIstr\fP translated to their
-corresponding upper-case counterparts. Non-alphabetic characters are
-left unchanged\*(CX
+corresponding upper-case counterparts. Non-alphabetic characters are
+left unchanged.\*(CX
.in -.2i
.EB "\s+2\f(HBSTRING FUNCTIONS\*(FR\s0"
@@ -1194,25 +1370,25 @@ formatting them.
turns \*(FIdatespec\fP into a time
stamp of the same form as returned by \*(FCsystime()\*(FR.
The \*(FIdatespec\fP is a string of the form
-\*(FC"\*(FIYYYY MM DD HH MM SS\*(FC"\*(FR
+\*(FC"\*(FIYYYY MM DD HH MM SS\*(FC"\*(FR.
..
.ti -.2i
\*(FCstrftime(\*(FR[\*(FIformat \*(FR[\*(FC, \*(FItimestamp\*(FR]]\*(FC)\*(FR
.br
formats \*(FItimestamp\fP
-according to the specification in \*(FIformat\*(FR. The
+according to the specification in \*(FIformat\*(FR. The
\*(FItimestamp\fP should be of the same form as returned by
\*(FCsystime()\*(FR.
-If \*(FItimestamp\fP is missing, the current time of day is used. If
+If \*(FItimestamp\fP is missing, the current time of day is used. If
\*(FIformat\fP is missing, a default format equivalent to the output
-of \*(FIdate\*(FR(1) will be used
+of \*(FIdate\*(FR(1) will be used.
.ti -.2i
\*(FCsystime()\fP
.br
returns the current time of day as the number of
-seconds since the Epoch\*(CB
+seconds since the Epoch.\*(CB
.in -.2i
-.EB "\s+2\f(HBTIME FUNCTIONS\*(FR\s0"
+.EB "\s+2\f(HBTIME FUNCTIONS (\*(GK\f(HB)\*(FR\s0"
@@ -1229,7 +1405,7 @@ seconds since the Epoch\*(CB
.sp .5
.fi
Functions are executed when they are called from within expressions
-in either patterns or actions. Actual parameters supplied in the function
+in either patterns or actions. Actual parameters supplied in the function
call instantiate the formal parameters declared in the function.
Arrays are passed by reference, other variables are passed by value.
.sp .5
@@ -1248,7 +1424,7 @@ real parameters by extra spaces in the parameter list. For example:
.fi
.sp .5
The left parenthesis in a function call is required
-to immediately follow the function name,
+to immediately follow the function name
without any intervening white space.
This is to avoid a syntactic ambiguity with the concatenation operator.
This restriction does not apply to the built-in functions.
@@ -1311,30 +1487,41 @@ Historical AWK implementations have treated such usage as
equivalent to the \*(FCnext\fP statement.
\*(GK will support this usage if \*(FC\-\^\-traditional\fP
has been specified.\*(CB
-.EB "\s+2\f(HBHISTORICAL FEATURES\*(FR\s0"
+.EB "\s+2\f(HBHISTORICAL FEATURES (\*(GK\f(HB)\*(FR\s0"
.\" --- FTP Information
.ES
.nf
\*(CDHost: \*(FCftp.gnu.ai.mit.edu\*(FR
-File: \*(FC/pub/gnu/gawk-3.0.2.tar.gz\fP
- GNU \*(AK (\*(GK). There may be a later version
+File: \*(FC/pub/gnu/gawk-3.0.3.tar.gz\fP
+.in +.2i
+.fi
+GNU \*(AK (\*(GK). There may be a later version.
+.in -.2i
+.nf
.sp .5
Host: \*(FCnetlib.bell-labs.com\*(FR
File: \*(FC/netlib/research/awk.bundle.Z\fP
- \*(NK. This version requires an ANSI C compiler;
- GCC (the GNU C compiler) works well
+.in +.2i
+.fi
+\*(NK. This version requires an ANSI C compiler;
+GCC (the GNU C compiler) works well.
+.in -.2i
+.nf
.sp .5
Host: \*(FCftp.whidbey.net\*(FR
File: \*(FC/pub/brennan/mawk1.3.3.tar.gz\fP
- Michael Brennan's \*(MK. There may be a newer version\*(CX
+.in +.2i
+.fi
+Michael Brennan's \*(MK. There may be a newer version.\*(CX
+.in -.2i
.EB "\s+2\f(HBFTP INFORMATION\*(FR\s0"
.\" --- Copying Permissions
.ES
.fi
-\*(CDCopyright \(co 1996 Free Software Foundation, Inc.
+\*(CDCopyright \(co 1996, 1997 Free Software Foundation, Inc.
.sp .5
Permission is granted to make and distribute verbatim copies of this
reference card provided the copyright notice and this permission notice