aboutsummaryrefslogtreecommitdiffstats
path: root/doc/gawk.1
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2010-07-16 12:57:07 +0300
committerArnold D. Robbins <arnold@skeeve.com>2010-07-16 12:57:07 +0300
commit3ca7f0b16d0a5c105380b284a81c6a1b2c210908 (patch)
treec2153d226b9cba3ebca0c3556b19bf3e52cd20dd /doc/gawk.1
parentf20ab7c3039a4023f41372bfe4bde3b16d481df7 (diff)
downloadegawk-3ca7f0b16d0a5c105380b284a81c6a1b2c210908.tar.gz
egawk-3ca7f0b16d0a5c105380b284a81c6a1b2c210908.tar.bz2
egawk-3ca7f0b16d0a5c105380b284a81c6a1b2c210908.zip
Move to gawk-3.0.5.
Diffstat (limited to 'doc/gawk.1')
-rw-r--r--doc/gawk.1359
1 files changed, 196 insertions, 163 deletions
diff --git a/doc/gawk.1 b/doc/gawk.1
index f15d4f1d..0b32ef78 100644
--- a/doc/gawk.1
+++ b/doc/gawk.1
@@ -1,28 +1,40 @@
.ds PX \s-1POSIX\s+1
.ds UX \s-1UNIX\s+1
.ds AN \s-1ANSI\s+1
-.TH GAWK 1 "Apr 28 1999" "Free Software Foundation" "Utility Commands"
+.ds GN \s-1GNU\s+1
+.ds AK \s-1AWK\s+1
+.if !\n(.g \{\
+. if !\w|\*(lq| \{\
+. ds lq ``
+. if \w'\(lq' .ds lq "\(lq
+. \}
+. if !\w|\*(rq| \{\
+. ds rq ''
+. if \w'\(rq' .ds rq "\(rq
+. \}
+.\}
+.TH GAWK 1 "May 17 2000" "Free Software Foundation" "Utility Commands"
.SH NAME
gawk \- pattern scanning and processing language
.SH SYNOPSIS
.B gawk
-[ POSIX or GNU style options ]
+[ \*(PX or \*(GN style options ]
.B \-f
.I program-file
[
.B \-\^\-
-] file .\^.\^.
+] file .\|.\|.
.br
.B gawk
-[ POSIX or GNU style options ]
+[ \*(PX or \*(GN style options ]
[
.B \-\^\-
]
.I program-text
-file .\^.\^.
+file .\|.\|.
.SH DESCRIPTION
.I Gawk
-is the GNU Project's implementation of the AWK programming language.
+is the \*(GN Project's implementation of the \*(AK programming language.
It conforms to the definition of the language in
the \*(PX 1003.2 Command Language And Utilities Standard.
This version in turn is based on the description in
@@ -34,11 +46,11 @@ of \*(UX
.I Gawk
also provides more recent Bell Labs
.I awk
-extensions, and some GNU-specific extensions.
+extensions, and some \*(GN-specific extensions.
.PP
The command line consists of options to
.I gawk
-itself, the AWK program text (if not supplied via the
+itself, the \*(AK program text (if not supplied via the
.B \-f
or
.B \-\^\-file
@@ -47,14 +59,14 @@ available in the
.B ARGC
and
.B ARGV
-pre-defined AWK variables.
+pre-defined \*(AK variables.
.SH OPTION FORMAT
.PP
.I Gawk
options may be either the traditional \*(PX one letter options,
-or the GNU style long options. \*(PX options start with a single ``\-'',
-while long options start with ``\-\^\-''.
-Long options are provided for both GNU-specific features and
+or the \*(GN style long options. \*(PX options start with a single \*(lq\-\*(rq,
+while long options start with \*(lq\-\^\-\*(rq.
+Long options are provided for both \*(GN-specific features and
for \*(PX mandated features.
.PP
Following the \*(PX standard,
@@ -103,14 +115,14 @@ to the variable
before execution of the program begins.
Such variable values are available to the
.B BEGIN
-block of an AWK program.
+block of an \*(AK program.
.TP
.PD 0
.BI \-f " program-file"
.TP
.PD
.BI \-\^\-file " program-file"
-Read the AWK program source from the file
+Read the \*(AK program source from the file
.IR program-file ,
instead of from the first command line argument.
Multiple
@@ -157,7 +169,7 @@ mode. In compatibility mode,
.I gawk
behaves identically to \*(UX
.IR awk ;
-none of the GNU-specific extensions are recognized.
+none of the \*(GN-specific extensions are recognized.
The use of
.B \-\^\-traditional
is preferred over the other forms of this option.
@@ -176,7 +188,7 @@ below, for more information.
.TP
.PD
.B \-\^\-copyright
-Print the short version of the GNU copyright information message on
+Print the short version of the \*(GN copyright information message on
the standard output, and exits successfully.
.TP
.PD 0
@@ -202,7 +214,7 @@ these options cause an immediate, successful exit.)
.PD
.B \-\^\-lint
Provide warnings about constructs that are
-dubious or non-portable to other AWK implementations.
+dubious or non-portable to other \*(AK implementations.
.TP
.PD 0
.B "\-W lint\-old"
@@ -231,7 +243,7 @@ users.
.PD
.B \-\^\-posix
This turns on
-.I compatibility
+.I compatibility
mode, with the following additional restrictions:
.RS
.TP \w'\(bu'u+1n
@@ -279,13 +291,13 @@ in regular expression matching
.BR "Regular Expressions" ,
below).
Interval expressions were not traditionally available in the
-AWK language. The POSIX standard added them, to make
+\*(AK language. The \*(PX standard added them, to make
.I awk
and
.I egrep
consistent with each other.
However, their use is likely
-to break old AWK programs, so
+to break old \*(AK programs, so
.I gawk
only provides them if they are requested with this option, or when
.B \-\^\-posix
@@ -298,13 +310,13 @@ is specified.
.BI \-\^\-source " program-text"
Use
.I program-text
-as AWK program source code.
-This option allows the easy intermixing of library functions (used via the
+as \*(AK program source code.
+This option allows the easy intermixing of library functions (used via the
.B \-f
and
.B \-\^\-file
options) with source code entered on the command line.
-It is intended primarily for medium to large AWK programs used
+It is intended primarily for medium to large \*(AK programs used
in shell scripts.
.TP
.PD 0
@@ -326,21 +338,21 @@ This is also useful when reporting bugs.
these options cause an immediate, successful exit.)
.TP
.B \-\^\-
-Signal the end of options. This is useful to allow further arguments to the
-AWK program itself to start with a ``\-''.
+Signal the end of options. This is useful to allow further arguments to the
+\*(AK program itself to start with a \*(lq\-\*(rq.
This is mainly for consistency with the argument parsing convention used
by most other \*(PX programs.
.PP
In compatibility mode,
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 the
+options are passed on to the \*(AK program in the
.B ARGV
-array for processing. This is particularly useful for running AWK
-programs via the ``#!'' executable interpreter mechanism.
+array for processing. This is particularly useful for running \*(AK
+programs via the \*(lq#!\*(rq executable interpreter mechanism.
.SH AWK PROGRAM EXECUTION
.PP
-An AWK program consists of a sequence of pattern-action statements
+An \*(AK program consists of a sequence of pattern-action statements
and optional function definitions.
.RS
.PP
@@ -366,14 +378,14 @@ will read the program text as if all the
.IR program-file s
and command line source texts
had been concatenated together. This is useful for building libraries
-of AWK functions, without having to include them in each new AWK
+of \*(AK functions, without having to include them in each new \*(AK
program that uses them. It also provides the ability to mix library
functions with command line programs.
.PP
The environment variable
.B AWKPATH
specifies a search path to use when finding source files named with
-the
+the
.B \-f
option. If this variable does not exist, the default path is
\fB".:/usr/local/share/awk"\fR.
@@ -382,10 +394,10 @@ option. If this variable does not exist, the default path is
was built and installed.)
If a file name given to the
.B \-f
-option contains a ``/'' character, no path search is performed.
+option contains a \*(lq/\*(rq character, no path search is performed.
.PP
.I Gawk
-executes AWK programs in the following order.
+executes \*(AK programs in the following order.
First,
all variable assignments specified via the
.B \-v
@@ -408,7 +420,7 @@ reads the standard input.
.PP
If a filename on the command line has the form
.IB var = val
-it is treated as a variable assignment. The variable
+it is treated as a variable assignment. The variable
.I var
will be assigned the value
.IR val .
@@ -417,8 +429,8 @@ will be assigned the value
block(s) have been run.)
Command line variable assignment
is most useful for dynamically assigning values to the variables
-AWK uses to control how input is broken into fields and records. It
-is also useful for controlling state if multiple passes are needed over
+\*(AK uses to control how input is broken into fields and records.
+It is also useful for controlling state if multiple passes are needed over
a single data file.
.PP
If the value of a particular element of
@@ -431,7 +443,7 @@ For each record in the input,
.I gawk
tests to see if it matches any
.I pattern
-in the AWK program.
+in the \*(AK program.
For each pattern that the record matches, the associated
.I action
is executed.
@@ -443,18 +455,18 @@ executes the code in the
.B END
block(s) (if any).
.SH VARIABLES, RECORDS AND FIELDS
-AWK variables are dynamic; they come into existence when they are
-first used. Their values are either floating-point numbers or strings,
+\*(AK variables are dynamic; they come into existence when they are
+first used. Their values are either floating-point numbers or strings,
or both,
-depending upon how they are used. AWK also has one dimensional
+depending upon how they are used. \*(AK also has one dimensional
arrays; arrays with multiple dimensions may be simulated.
Several pre-defined variables are set as a program
runs; these will be described as needed and summarized below.
.SS Records
-Normally, records are separated by newline characters. You can control how
+Normally, records are separated by newline characters. You can control how
records are separated by assigning values to the built-in variable
.BR RS .
-If
+If
.B RS
is any single character, that character separates records.
Otherwise,
@@ -498,7 +510,7 @@ In the special case that
is a single space, fields are separated
by runs of spaces and/or tabs and/or newlines.
(But see the discussion of
-.BR \-\-posix ,
+.BR \-\^\-posix ,
below).
Note that the value of
.B IGNORECASE
@@ -527,7 +539,7 @@ Each field in the input record may be referenced by its position,
.BR $2 ,
and so on.
.B $0
-is the whole record. The value of a field may be assigned to as well.
+is the whole record. The value of a field may be assigned to as well.
Fields need not be referenced by constants:
.RS
.PP
@@ -545,8 +557,8 @@ is set to the total number of fields in the input record.
.PP
References to non-existent fields (i.e. fields after
.BR $NF )
-produce the null-string. However, assigning to a non-existent field
-(e.g.,
+produce the null-string. However, assigning to a non-existent field
+(e.g.,
.BR "$(NF+2) = 5" )
will increase the value of
.BR NF ,
@@ -579,7 +591,7 @@ The index in
of the current file being processed.
.TP
.B ARGV
-Array of command line arguments. The array is indexed from
+Array of command line arguments. The array is indexed from
0 to
.B ARGC
\- 1.
@@ -632,7 +644,7 @@ evolves over time.
The name of the current input file.
If no files are specified on the command line, the value of
.B FILENAME
-is ``\-''.
+is \*(lq\-\*(rq.
However,
.B FILENAME
is undefined inside the
@@ -648,8 +660,8 @@ The input field separator, a space by default. See
above.
.TP
.B IGNORECASE
-Controls the case-sensitivity of all regular expression
-and string operations. If
+Controls the case-sensitivity of all regular expression
+and string operations. If
.B IGNORECASE
has a non-zero value, then string comparisons and
pattern matching in rules,
@@ -677,7 +689,7 @@ is not equal to zero,
.B /aB/
matches all of the strings \fB"ab"\fP, \fB"aB"\fP, \fB"Ab"\fP,
and \fB"AB"\fP.
-As with all AWK variables, the initial value of
+As with all \*(AK variables, the initial value of
.B IGNORECASE
is zero, so all regular expression and string
operations are normally case-sensitive.
@@ -688,7 +700,7 @@ In versions of
.I gawk
prior to 3.0,
.B IGNORECASE
-only affected regular expression operations. It now affects string
+only affected regular expression operations. It now affects string
comparisons as well.
.TP
.B NF
@@ -736,14 +748,14 @@ elements, by default \fB"\e034"\fR.
Arrays are subscripted with an expression between square brackets
.RB ( [ " and " ] ).
If the expression is an expression list
-.RI ( expr ", " expr " ...)"
+.RI ( expr ", " expr " .\|.\|.)"
then the array subscript is a string consisting of the
concatenation of the (string) value of each expression,
separated by the value of the
.B SUBSEP
variable.
This facility is used to simulate multiply dimensioned
-arrays. For example:
+arrays. For example:
.PP
.RS
.ft B
@@ -755,7 +767,7 @@ x[i, j, k] = "hello, world\en"
.PP
assigns the string \fB"hello, world\en"\fR to the element of the array
.B x
-which is indexed by the string \fB"A\e034B\e034C"\fR. All arrays in AWK
+which is indexed by the string \fB"A\e034B\e034C"\fR. All arrays in \*(AK
are associative, i.e. indexed by string values.
.PP
The special operator
@@ -795,8 +807,8 @@ just by specifying the array name without a subscript.
.SS Variable Typing And Conversion
.PP
Variables and fields
-may be (floating point) numbers, or strings, or both. How the
-value of a variable is interpreted depends upon its context. If used in
+may be (floating point) numbers, or strings, or both. How the
+value of a variable is interpreted depends upon its context. 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.
.PP
@@ -811,7 +823,7 @@ A number is converted to a string by using the value of
as a format string for
.IR sprintf (3),
with the numeric value of the variable as the argument.
-However, even though all numbers in AWK are floating-point,
+However, even though all numbers in \*(AK are floating-point,
integral values are
.I always
converted as integers. Thus, given
@@ -834,7 +846,7 @@ has a string value of \fB"12"\fR and not \fB"12.00"\fR.
performs comparisons 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.
+\*(lqnumeric string,\*(rq then comparisons are also done numerically.
Otherwise, the numeric value is converted to a string and a string
comparison is performed.
Two strings are compared, of course, as strings.
@@ -846,7 +858,8 @@ does not do this.
.PP
Note that string constants, such as \fB"57"\fP, are
.I not
-numeric strings, they are string constants. The idea of ``numeric string''
+numeric strings, they are string constants.
+The idea of \*(lqnumeric string\*(rq
only applies to fields,
.B getline
input,
@@ -865,13 +878,13 @@ should be treated that way.
Uninitialized variables have the numeric value 0 and the string value ""
(the null, or empty, string).
.SH PATTERNS AND ACTIONS
-AWK is a line oriented language. The pattern comes first, and then the
-action. Action statements are enclosed in
+\*(AK is a line-oriented language. The pattern comes first, and then the
+action. Action statements are enclosed in
.B {
and
.BR } .
Either the pattern may be missing, or the action may be missing, but,
-of course, not both. If the pattern is missing, the action will be
+of course, not both. If the pattern is missing, the action will be
executed for every single record of input.
A missing action is equivalent to
.RS
@@ -881,12 +894,12 @@ A missing action is equivalent to
.PP
which prints the entire record.
.PP
-Comments begin with the ``#'' character, and continue until the
+Comments begin with the \*(lq#\*(rq character, and continue until the
end of the line.
Blank lines may be used to separate statements.
Normally, a statement ends with a newline, however, this is not the
case for lines ending in
-a ``,'',
+a \*(lq,\*(rq,
.BR { ,
.BR ? ,
.BR : ,
@@ -898,16 +911,16 @@ Lines ending in
or
.B else
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 other cases, a line can be continued by ending it with a \*(lq\e\*(rq,
in which case the newline will be ignored.
.PP
Multiple statements may
-be put on one line by separating them with a ``;''.
+be put on one line by separating them with a \*(lq;\*(rq.
This applies to both the statements within the action part of a
pattern-action pair (the usual case),
and to the pattern-action statements themselves.
.SS Patterns
-AWK patterns may be one of the following:
+\*(AK patterns may be one of the following:
.PP
.RS
.nf
@@ -934,8 +947,8 @@ The action parts of all
patterns are merged as if all the statements had
been written in a single
.B BEGIN
-block. They are executed before any
-of the input is read. Similarly, all the
+block. They are executed before any
+of the input is read. Similarly, all the
.B END
blocks are merged,
and executed when all the input is exhausted (or when an
@@ -970,16 +983,16 @@ and
.B !
operators are logical AND, logical OR, and logical NOT, respectively, as in C.
They do short-circuit evaluation, also as in C, and are used for combining
-more primitive pattern expressions. As in most languages, parentheses
+more primitive pattern expressions. As in most languages, parentheses
may be used to change the order of evaluation.
.PP
The
.B ?\^:
-operator is like the same operator in C. If the first pattern is true
+operator is like the same operator in C. If the first pattern is true
then the pattern used for testing is the second pattern, otherwise it is
-the third. Only one of the second and third patterns is evaluated.
+the third. Only one of the second and third patterns is evaluated.
.PP
-The
+The
.IB pattern1 ", " pattern2
form of an expression is called a
.IR "range pattern" .
@@ -987,12 +1000,12 @@ It matches all input records starting with a record that matches
.IR pattern1 ,
and continuing until a record that matches
.IR pattern2 ,
-inclusive. It does not combine with any other sort of pattern expression.
+inclusive. It does not combine with any other sort of pattern expression.
.SS Regular Expressions
Regular expressions are the extended kind found in
.IR egrep .
They are composed of characters as follows:
-.TP \w'\fB[^\fIabc...\fB]\fR'u+2n
+.TP \w'\fB[^\fIabc.\|.\|.\fB]\fR'u+2n
.I c
matches the non-metacharacter
.IR c .
@@ -1012,13 +1025,13 @@ matches the beginning of a string.
.B $
matches the end of a string.
.TP
-.BI [ abc... ]
+.BI [ abc.\|.\|. ]
character list, matches any of the characters
-.IR abc... .
+.IR abc.\|.\|. .
.TP
-.BI [^ abc... ]
+.BI [^ abc.\|.\|. ]
negated character list, matches any character except
-.IR abc... .
+.IR abc.\|.\|. .
.TP
.IB r1 | r2
alternation: matches either
@@ -1034,15 +1047,15 @@ and then
.TP
.IB r +
matches one or more
-.IR r 's.
+.IR r 's.
.TP
.IB r *
matches zero or more
-.IR r 's.
+.IR r 's.
.TP
.IB r ?
matches zero or one
-.IR r 's.
+.IR r 's.
.TP
.BI ( r )
grouping: matches
@@ -1110,9 +1123,9 @@ The escape sequences that are valid in string constants (see below)
are also legal in regular expressions.
.PP
.I "Character classes"
-are a new feature introduced in the POSIX standard.
+are a new feature introduced in the \*(PX standard.
A character class is a special notation for describing
-lists of characters that have a specific attribute, but where the
+lists of characters that have a specific attribute, but where the
actual characters themselves can vary from country to country and/or
from character set to character set. For example, the notion of what
is an alphabetic character differs in the USA and in France.
@@ -1124,7 +1137,7 @@ the brackets of a character list. Character classes consist of
a keyword denoting the class, and
.BR :] .
Here are the character
-classes defined by the POSIX standard.
+classes defined by the \*(PX standard.
.TP
.B [:alnum:]
Alphanumeric characters.
@@ -1166,11 +1179,11 @@ Upper-case alphabetic characters.
.B [:xdigit:]
Characters that are hexadecimal digits.
.PP
-For example, before the POSIX standard, to match alphanumeric
+For example, before the \*(PX standard, to match alphanumeric
characters, you would have had to write
.BR /[A\-Za\-z0\-9]/ .
If your character set had other alphabetic characters in it, this would not
-match them. With the POSIX character classes, you can write
+match them. With the \*(PX character classes, you can write
.BR /[[:alnum:]]/ ,
and this will match
.I all
@@ -1178,12 +1191,12 @@ the alphabetic and numeric characters in your character set.
.PP
Two additional special sequences can appear in character lists.
These apply to non-ASCII character sets, which can have single symbols
-(called
+(called
.IR "collating elements" )
that are represented with more than one
character, as well as several characters that are equivalent for
.IR collating ,
-or sorting, purposes. (E.g., in French, a plain ``e''
+or sorting, purposes. (E.g., in French, a plain \*(lqe\*(rq
and a grave-accented e\` are equivalent.)
.TP
Collating Symbols
@@ -1204,14 +1217,14 @@ or
.TP
Equivalence Classes
An equivalence class is a locale-specific name for a list of
-characters that are equivalent. The name is enclosed in
+characters that are equivalent. The name is enclosed in
.B [=
and
.BR =] .
For example, the name
.B e
might be used to represent all of
-``e,'' ``e\`,'' and ``e\`.''
+\*(lqe,\*(rq \*(lqe\`,\*(rq and \*(lqe\`.\*(rq
In this case,
.B [[=e]]
is a regexp
@@ -1225,7 +1238,7 @@ These features are very valuable in non-English speaking locales.
The library functions that
.I gawk
uses for regular expression matching
-currently only recognize POSIX character classes; they do not recognize
+currently only recognize \*(PX character classes; they do not recognize
collating symbols or equivalence classes.
.PP
The
@@ -1240,7 +1253,7 @@ and
.B \e'
operators are specific to
.IR gawk ;
-they are extensions based on facilities in the GNU regexp libraries.
+they are extensions based on facilities in the \*(GN regexp libraries.
.PP
The various command line options
control how
@@ -1251,11 +1264,11 @@ No options
In the default case,
.I gawk
provide all the facilities of
-POSIX regexps and the GNU regexp operators described above.
+\*(PX regexps and the \*(GN regexp operators described above.
However, interval expressions are not supported.
.TP
.B \-\^\-posix
-Only POSIX regexps are supported, the GNU operators are not special.
+Only \*(PX regexps are supported, the \*(GN operators are not special.
(E.g.,
.B \ew
matches a literal
@@ -1265,9 +1278,9 @@ Interval expressions are allowed.
.B \-\^\-traditional
Traditional Unix
.I awk
-regexps are matched. The GNU operators
+regexps are matched. The \*(GN operators
are not special, interval expressions are not available, and neither
-are the POSIX character classes
+are the \*(PX character classes
.RB ( [[:alnum:]]
and so on).
Characters described by octal and hexadecimal escape sequences are
@@ -1283,15 +1296,15 @@ Action statements are enclosed in braces,
and
.BR } .
Action statements consist of the usual assignment, conditional, and looping
-statements found in most languages. The operators, control statements,
+statements found in most languages. The operators, control statements,
and input/output statements
available are patterned after those in C.
.SS Operators
.PP
-The operators in AWK, in order of decreasing precedence, are
+The operators in \*(AK, in order of decreasing precedence, are
.PP
.TP "\w'\fB*= /= %= ^=\fR'u+1n"
-.BR ( \&... )
+.BR ( \&.\|.\|. )
Grouping
.TP
.B $
@@ -1352,9 +1365,10 @@ Logical AND.
Logical OR.
.TP
.B ?:
-The C conditional expression. This has the form
+The C conditional expression. This has the form
.IB expr1 " ? " expr2 " : " expr3\c
-\&. If
+\&.
+If
.I expr1
is true, the value of the expression is
.IR expr2 ,
@@ -1371,7 +1385,7 @@ is evaluated.
.TP
.PD
.B "*= /= %= ^="
-Assignment. Both absolute assignment
+Assignment. Both absolute assignment
.BI ( var " = " value )
and operator-assignment (the other forms) are supported.
.SS Control Statements
@@ -1432,9 +1446,9 @@ from next record of
.IR file .
.TP
.B next
-Stop processing the current input record. The next input record
+Stop processing the current input record. The next input record
is read and processing starts over with the first pattern in the
-AWK program. If the end of the input data is reached, the
+\*(AK program. If the end of the input data is reached, the
.B END
block(s), if any, are executed.
.TP
@@ -1447,13 +1461,13 @@ and
are updated,
.B FNR
is reset to 1, and processing starts over with the first pattern in the
-AWK program. If the end of the input data is reached, the
+\*(AK program. If the end of the input data is reached, the
.B END
block(s), if any, are executed.
.B NOTE:
Earlier versions of gawk used
.BR "next file" ,
-as two words. While this usage is still recognized, it generates a
+as two words. While this usage is still recognized, it generates a
warning message and will eventually be removed.
.TP
.B print
@@ -1476,7 +1490,7 @@ Prints expressions on
.IR file .
Each expression is separated by the value of the
.B OFS
-variable. The output record is terminated with the value of the
+variable. The output record is terminated with the value of the
.B ORS
variable.
.TP
@@ -1505,11 +1519,11 @@ is the null string,
then all open output files and pipes
have their buffers flushed.
.PP
-Other input/output redirections are also allowed. For
+Other input/output redirections are also allowed. For
.B print
and
.BR printf ,
-.BI >> file
+.BI >> " file"
appends output to the
.IR file ,
while
@@ -1522,9 +1536,23 @@ pipes into
The
.BR getline
command will return 0 on end of file, and \-1 on an error.
+.PP
+NOTE: If using a pipe to
+.BR getline ,
+or from
+.B print
+or
+.BR printf
+within a loop, you
+.I must
+use
+.B close()
+to create new instances of the command.
+AWK does not automatically close pipes when
+they return EOF.
.SS The \fIprintf\fP\^ Statement
.PP
-The AWK versions of the
+The \*(AK versions of the
.B printf
statement and
.B sprintf()
@@ -1583,7 +1611,11 @@ instead of
.BR %e .
.TP
.B %o
-An unsigned octal number (again, an integer).
+An unsigned octal number (also an integer).
+.TP
+.PD
+.B %u
+An unsigned decimal number (again, an integer).
.TP
.B %s
A character string.
@@ -1594,7 +1626,7 @@ A character string.
.PD
.B %X
An unsigned hexadecimal number (an integer).
-.The
+The
.B %X
format uses
.B ABCDEF
@@ -1620,12 +1652,12 @@ negative values with a minus sign.
.B +
The plus sign, used before the width modifier (see below),
says to always supply a sign for numeric conversions, even if the data
-to be formatted is positive. The
+to be formatted is positive. The
.B +
overrides the space modifier.
.TP
.B #
-Use an ``alternate form'' for certain control letters.
+Use an \*(lqalternate form\*(rq for certain control letters.
For
.BR %o ,
supply a leading zero.
@@ -1634,9 +1666,9 @@ For
and
.BR %X ,
supply a leading
-.BR 0x
+.BR 0x
or
-.BR 0X
+.BR 0X
for
a nonzero result.
For
@@ -1662,7 +1694,7 @@ This flag only has an effect when the field width is wider than the
value to be printed.
.TP
.I width
-The field should be padded to this width. The field is normally padded
+The field should be padded to this width. The field is normally padded
with spaces. If the
.B 0
flag has been used, it is padded with zeroes.
@@ -1673,7 +1705,7 @@ For the
.BR %e ,
.BR %E ,
and
-.BR %f
+.BR %f
formats, this specifies the
number of digits you want printed to the right of the decimal point.
For the
@@ -1779,7 +1811,7 @@ The standard error output.
The file associated with the open file descriptor
.IR n .
.PP
-These are particularly useful for error messages. For example:
+These are particularly useful for error messages. For example:
.PP
.RS
.ft B
@@ -1798,7 +1830,7 @@ print "You blew it!" | "cat 1>&2"
These file names may also be used on the command line to name data files.
.SS Numeric Functions
.PP
-AWK has the following pre-defined arithmetic functions:
+\*(AK has the following pre-defined arithmetic functions:
.PP
.TP \w'\fBsrand(\fR[\fIexpr\^\fR]\fB)\fR'u+1n
.BI atan2( y , " x" )
@@ -1834,7 +1866,7 @@ the square root function.
\&\fBsrand(\fR[\fIexpr\^\fR]\fB)\fR
uses
.I expr
-as a new seed for the random number generator. If no
+as a new seed for the random number generator. If no
.I expr
is provided, the time of day will be used.
The return value is the previous seed for the random
@@ -1879,7 +1911,7 @@ where
is a digit from 1 to 9, may be used to indicate just the text that
matched the
.IR n 'th
-parenthesized subexpression. The sequence
+parenthesized subexpression. The sequence
.B \e0
represents the entire matched text, as does the character
.BR & .
@@ -1912,7 +1944,7 @@ Use
to get a literal
.BR & .
See
-.I "AWK Language Programming"
+.I "Effective AWK Programming"
for a fuller discussion of the rules for
.BR &'s
and backslashes in the replacement text of
@@ -1958,7 +1990,7 @@ into the array
.I a
on the regular expression
.IR r ,
-and returns the number of fields. If
+and returns the number of fields. If
.I r
is omitted,
.B FS
@@ -2010,7 +2042,7 @@ translated to their corresponding upper-case counterparts.
Non-alphabetic characters are left unchanged.
.SS Time Functions
.PP
-Since one of the primary uses of AWK programs is processing log files
+Since one of the primary uses of \*(AK programs is processing log files
that contain time stamp information,
.I gawk
provides the following two functions for obtaining time stamps and
@@ -2052,17 +2084,17 @@ then all of the conversions described in that man page are available to
.IR gawk.
.SS String Constants
.PP
-String constants in AWK are sequences of characters enclosed
-between double quotes (\fB"\fR). Within strings, certain
+String constants in \*(AK are sequences of characters enclosed
+between double quotes (\fB"\fR). Within strings, certain
.I "escape sequences"
-are recognized, as in C. These are:
+are recognized, as in C. These are:
.PP
.TP \w'\fB\e\^\fIddd\fR'u+1n
.B \e\e
A literal backslash.
.TP
.B \ea
-The ``alert'' character; usually the \s-1ASCII\s+1 \s-1BEL\s+1 character.
+The \*(lqalert\*(rq character; usually the \s-1ASCII\s+1 \s-1BEL\s+1 character.
.TP
.B \eb
backspace.
@@ -2093,7 +2125,8 @@ E.g., \fB"\ex1B"\fR is the \s-1ASCII\s+1 \s-1ESC\s+1 (escape) character.
.TP
.BI \e ddd
The character represented by the 1-, 2-, or 3-digit sequence of octal
-digits. E.g. \fB"\e033"\fR is the \s-1ASCII\s+1 \s-1ESC\s+1 (escape) character.
+digits.
+E.g., \fB"\e033"\fR is the \s-1ASCII\s+1 \s-1ESC\s+1 (escape) character.
.TP
.BI \e c
The literal character
@@ -2106,12 +2139,12 @@ matches whitespace characters).
.PP
In compatibility mode, the characters represented by octal and
hexadecimal escape sequences are treated literally when used in
-regexp constants. Thus,
+regexp constants. Thus,
.B /a\e52b/
is equivalent to
.BR /a\e*b/ .
.SH FUNCTIONS
-Functions in AWK are defined as follows:
+Functions in \*(AK are defined as follows:
.PP
.RS
\fBfunction \fIname\fB(\fIparameter list\fB) { \fIstatements \fB}\fR
@@ -2122,20 +2155,20 @@ in either patterns or actions. Actual parameters supplied in the function
call are used to instantiate the formal parameters declared in the function.
Arrays are passed by reference, other variables are passed by value.
.PP
-Since functions were not originally part of the AWK language, the provision
+Since functions were not originally part of the \*(AK language, the provision
for local variables is rather clumsy: They are declared as extra parameters
-in the parameter list. The convention is to separate local variables from
-real parameters by extra spaces in the parameter list. For example:
+in the parameter list. The convention is to separate local variables from
+real parameters by extra spaces in the parameter list. For example:
.PP
.RS
.ft B
.nf
function f(p, q, a, b) # a & b are local
{
- \&.....
+ \&.\|.\|.
}
-/abc/ { ... ; f(1, 2) ; ... }
+/abc/ { .\|.\|. ; f(1, 2) ; .\|.\|. }
.fi
.ft R
.RE
@@ -2152,8 +2185,8 @@ to the null string and the number zero upon function invocation.
.PP
Use
.BI return " expr"
-to return a value from a function. The return value is undefined if no
-value is provided, or if the function returns by ``falling off'' the
+to return a value from a function. The return value is undefined if no
+value is provided, or if the function returns by \*(lqfalling off\*(rq the
end.
.PP
If
@@ -2209,9 +2242,9 @@ Concatenate and line number (a variation on a theme):
.PP
.IR "The AWK Programming Language" ,
Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger,
-Addison-Wesley, 1988. ISBN 0-201-07981-X.
+Addison-Wesley, 1988. ISBN 0-201-07981-X.
.PP
-.IR "AWK Language Programming" ,
+.IR "Effective AWK Programming" ,
Edition 1.0, published by the Free Software Foundation, 1995.
.SH POSIX COMPATIBILITY
A primary goal for
@@ -2222,7 +2255,7 @@ latest version of \*(UX
To this end,
.I gawk
incorporates the following user visible
-features which are not described in the AWK book,
+features which are not described in the \*(AK book,
but are part of the Bell Labs version of
.IR awk ,
and are in the \*(PX standard.
@@ -2239,12 +2272,12 @@ assignment appeared before any file names, the assignment would happen
.I before
the
.B BEGIN
-block was run. Applications came to depend on this ``feature.''
+block was run. Applications came to depend on this \*(lqfeature.\*(rq
When
.I awk
was changed to match its documentation, this option was added to
accommodate applications that depended upon the old behavior.
-(This feature was agreed upon by both the AT&T and GNU developers.)
+(This feature was agreed upon by both the AT&T and \*(GN developers.)
.PP
The
.B \-W
@@ -2252,18 +2285,18 @@ option for implementation specific features is from the \*(PX standard.
.PP
When processing arguments,
.I gawk
-uses the special option ``\fB\-\^\-\fP'' to signal the end of
+uses the special option \*(lq\-\^\-\*(rq to signal the end of
arguments.
In compatibility mode, it will warn about, but otherwise ignore,
undefined options.
-In normal operation, such arguments are passed on to the AWK program for
+In normal operation, such arguments are passed on to the \*(AK program for
it to process.
.PP
-The AWK book does not define the return value of
+The \*(AK book does not define the return value of
.BR srand() .
The \*(PX standard
has it return the seed it was using, to allow keeping track
-of random number sequences. Therefore
+of random number sequences. Therefore
.B srand()
in
.I gawk
@@ -2401,13 +2434,13 @@ if the
.I fs
argument to the
.B \-F
-option is ``t'', then
+option is \*(lqt\*(rq, then
.B FS
will be set to the tab character.
Note that typing
-.B "gawk \-F\et \&..."
-simply causes the shell to quote the ``t,'', and does not pass
-``\et'' to the
+.B "gawk \-F\et \&.\|.\|."
+simply causes the shell to quote the \*(lqt,\*(rq, and does not pass
+\*(lq\et\*(rq to the
.B \-F
option.
Since this is a rather ugly special case, it is not the default behavior.
@@ -2416,7 +2449,7 @@ This behavior also does not occur if
has been specified.
To really get a tab character as the field separator, it is best to use
quotes:
-.BR "gawk \-F'\et' \&..." .
+.BR "gawk \-F'\et' \&.\|.\|." .
.ig
.PP
If
@@ -2440,7 +2473,7 @@ maintainers, and may not even be compiled into
.IR gawk .
..
.SH HISTORICAL FEATURES
-There are two features of historical AWK implementations that
+There are two features of historical \*(AK implementations that
.I gawk
supports.
First, it is possible to call the
@@ -2464,7 +2497,7 @@ a = length($0)
.ft R
.RE
.PP
-This feature is marked as ``deprecated'' in the \*(PX standard, and
+This feature is marked as \*(lqdeprecated\*(rq in the \*(PX standard, and
.I gawk
will issue a warning about its use if
.B \-\^\-lint
@@ -2479,7 +2512,7 @@ statements outside the body of a
.BR for ,
or
.B do
-loop. Traditional AWK implementations have treated such usage as
+loop. Traditional \*(AK implementations have treated such usage as
equivalent to the
.B next
statement.
@@ -2541,12 +2574,12 @@ and the effort to do so really is not worth it.
.SH VERSION INFORMATION
This man page documents
.IR gawk ,
-version 3.0.4.
+version 3.0.5.
.SH AUTHORS
The original version of \*(UX
.I awk
was designed and implemented by Alfred Aho,
-Peter Weinberger, and Brian Kernighan of AT&T Bell Labs. Brian Kernighan
+Peter Weinberger, and Brian Kernighan of AT&T Bell Labs. Brian Kernighan
continues to maintain and enhance it.
.PP
Paul Rubin and Jay Fenlason,
@@ -2581,7 +2614,7 @@ Please include your operating system and its revision, the version of
what C compiler you used to compile it, and a test program
and data that are as small as possible for reproducing the problem.
.PP
-Before sending a bug report, please do two things. First, verify that
+Before sending a bug report, please do two things. First, verify that
you have the latest version of
.IR gawk .
Many bugs (usually subtle ones) are fixed at each release, and if
@@ -2597,14 +2630,14 @@ post a bug report in
While the
.I gawk
developers occasionally read this newsgroup, posting bug reports there
-is an unreliable way to report bugs. Instead, please use the electronic mail
+is an unreliable way to report bugs. Instead, please use the electronic mail
addresses given above.
.SH ACKNOWLEDGEMENTS
Brian Kernighan of Bell Labs
provided valuable assistance during testing and debugging.
We thank him.
.SH COPYING PERMISSIONS
-Copyright \(co) 1996,97,98,99 Free Software Foundation, Inc.
+Copyright \(co 1996\-2000 Free Software Foundation, Inc.
.PP
Permission is granted to make and distribute verbatim copies of
this manual page provided the copyright notice and this permission