Final cleanup. After giving up on trying to avoid having two loader*.conf
[dragonfly.git] / contrib / awk / doc / awk.1
1 .\" $FreeBSD: src/contrib/awk/doc/awk.1,v 1.5 1999/09/27 08:57:04 sheldonh Exp $
2 .\" $DragonFly: src/contrib/awk/doc/Attic/awk.1,v 1.2 2003/06/17 04:23:58 dillon Exp $
3 .ds PX \s-1POSIX\s+1
4 .ds UX \s-1UNIX\s+1
5 .ds AN \s-1ANSI\s+1
6 .TH GAWK 1 "Apr 28 1999" "Free Software Foundation" "Utility Commands"
7 .SH NAME
8 gawk \- pattern scanning and processing language
9 .SH SYNOPSIS
10 .B gawk
11 [ POSIX or GNU style options ]
12 .B \-f
13 .I program-file
14 [
15 .B \-\^\-
16 ] file .\^.\^.
17 .br
18 .B gawk
19 [ POSIX or GNU style options ]
20 [
21 .B \-\^\-
22 ]
23 .I program-text
24 file .\^.\^.
25 .SH DESCRIPTION
26 .I Gawk
27 is the GNU Project's implementation of the AWK programming language.
28 It conforms to the definition of the language in
29 the \*(PX 1003.2 Command Language And Utilities Standard.
30 This version in turn is based on the description in
31 .IR "The AWK Programming Language" ,
32 by Aho, Kernighan, and Weinberger,
33 with the additional features found in the System V Release 4 version
34 of \*(UX
35 .IR awk .
36 .I Gawk
37 also provides more recent Bell Labs
38 .I awk
39 extensions, and some GNU-specific extensions.
40 .PP
41 The command line consists of options to
42 .I gawk
43 itself, the AWK program text (if not supplied via the
44 .B \-f
45 or
46 .B \-\^\-file
47 options), and values to be made
48 available in the
49 .B ARGC
50 and
51 .B ARGV
52 pre-defined AWK variables.
53 .SH OPTION FORMAT
54 .PP
55 .I Gawk
56 options may be either the traditional \*(PX one letter options,
57 or the GNU style long options.  \*(PX options start with a single ``\-'',
58 while long options start with ``\-\^\-''.
59 Long options are provided for both GNU-specific features and
60 for \*(PX mandated features.
61 .PP
62 Following the \*(PX standard,
63 .IR gawk -specific
64 options are supplied via arguments to the
65 .B \-W
66 option.  Multiple
67 .B \-W
68 options may be supplied
69 Each
70 .B \-W
71 option has a corresponding long option, as detailed below.
72 Arguments to long options are either joined with the option
73 by an
74 .B =
75 sign, with no intervening spaces, or they may be provided in the
76 next command line argument.
77 Long options may be abbreviated, as long as the abbreviation
78 remains unique.
79 .SH OPTIONS
80 .PP
81 .I Gawk
82 accepts the following options.
83 .TP
84 .PD 0
85 .BI \-F " fs"
86 .TP
87 .PD
88 .BI \-\^\-field-separator " fs"
89 Use
90 .I fs
91 for the input field separator (the value of the
92 .B FS
93 predefined
94 variable).
95 .TP
96 .PD 0
97 \fB\-v\fI var\fB\^=\^\fIval\fR
98 .TP
99 .PD
100 \fB\-\^\-assign \fIvar\fB\^=\^\fIval\fR
101 Assign the value
102 .IR val ,
103 to the variable
104 .IR var ,
105 before execution of the program begins.
106 Such variable values are available to the
107 .B BEGIN
108 block of an AWK program.
109 .TP
110 .PD 0
111 .BI \-f " program-file"
112 .TP
113 .PD
114 .BI \-\^\-file " program-file"
115 Read the AWK program source from the file
116 .IR program-file ,
117 instead of from the first command line argument.
118 Multiple
119 .B \-f
120 (or
121 .BR \-\^\-file )
122 options may be used.
123 .TP
124 .PD 0
125 .BI \-mf " NNN"
126 .TP
127 .PD
128 .BI \-mr " NNN"
129 Set various memory limits to the value
130 .IR NNN .
131 The
132 .B f
133 flag sets the maximum number of fields, and the
134 .B r
135 flag sets the maximum record size.  These two flags and the
136 .B \-m
137 option are from the Bell Labs research version of \*(UX
138 .IR awk .
139 They are ignored by
140 .IR gawk ,
141 since
142 .I gawk
143 has no pre-defined limits.
144 .TP
145 .PD 0
146 .B "\-W traditional"
147 .TP
148 .PD 0
149 .B "\-W compat"
150 .TP
151 .PD 0
152 .B \-\^\-traditional
153 .TP
154 .PD
155 .B \-\^\-compat
156 Run in
157 .I compatibility
158 mode.  In compatibility mode,
159 .I gawk
160 behaves identically to \*(UX
161 .IR awk ;
162 none of the GNU-specific extensions are recognized.
163 The use of
164 .B \-\^\-traditional
165 is preferred over the other forms of this option.
166 See
167 .BR "GNU EXTENSIONS" ,
168 below, for more information.
169 .TP
170 .PD 0
171 .B "\-W copyleft"
172 .TP
173 .PD 0
174 .B "\-W copyright"
175 .TP
176 .PD 0
177 .B \-\^\-copyleft
178 .TP
179 .PD
180 .B \-\^\-copyright
181 Print the short version of the GNU copyright information message on
182 the standard output, and exits successfully.
183 .TP
184 .PD 0
185 .B "\-W help"
186 .TP
187 .PD 0
188 .B "\-W usage"
189 .TP
190 .PD 0
191 .B \-\^\-help
192 .TP
193 .PD
194 .B \-\^\-usage
195 Print a relatively short summary of the available options on
196 the standard output.
197 (Per the
198 .IR "GNU Coding Standards" ,
199 these options cause an immediate, successful exit.)
200 .TP
201 .PD 0
202 .B "\-W lint"
203 .TP
204 .PD
205 .B \-\^\-lint
206 Provide warnings about constructs that are
207 dubious or non-portable to other AWK implementations.
208 .TP
209 .PD 0
210 .B "\-W lint\-old"
211 .TP
212 .PD
213 .B \-\^\-lint\-old
214 Provide warnings about constructs that are
215 not portable to the original version of Unix
216 .IR awk .
217 .ig
218 .\" This option is left undocumented, on purpose.
219 .TP
220 .PD 0
221 .B "\-W nostalgia"
222 .TP
223 .PD
224 .B \-\^\-nostalgia
225 Provide a moment of nostalgia for long time
226 .I awk
227 users.
228 ..
229 .TP
230 .PD 0
231 .B "\-W posix"
232 .TP
233 .PD
234 .B \-\^\-posix
235 This turns on
236 .I compatibility 
237 mode, with the following additional restrictions:
238 .RS
239 .TP \w'\(bu'u+1n
240 \(bu
241 .B \ex
242 escape sequences are not recognized.
243 .TP
244 \(bu
245 Only space and tab act as field separators when
246 .B FS
247 is set to a single space, newline does not.
248 .TP
249 \(bu
250 The synonym
251 .B func
252 for the keyword
253 .B function
254 is not recognized.
255 .TP
256 \(bu
257 The operators
258 .B **
259 and
260 .B **=
261 cannot be used in place of
262 .B ^
263 and
264 .BR ^= .
265 .TP
266 \(bu
267 The
268 .B fflush()
269 function is not available.
270 .RE
271 .TP
272 .PD 0
273 .B "\-W re\-interval"
274 .TP
275 .PD
276 .B \-\^\-re\-interval
277 Enable the use of
278 .I "interval expressions"
279 in regular expression matching
280 (see
281 .BR "Regular Expressions" ,
282 below).
283 Interval expressions were not traditionally available in the
284 AWK language. The POSIX standard added them, to make
285 .I awk
286 and
287 .I egrep
288 consistent with each other.
289 However, their use is likely
290 to break old AWK programs, so
291 .I gawk
292 only provides them if they are requested with this option, or when
293 .B \-\^\-posix
294 is specified.
295 .TP
296 .PD 0
297 .BI "\-W source " program-text
298 .TP
299 .PD
300 .BI \-\^\-source " program-text"
301 Use
302 .I program-text
303 as AWK program source code.
304 This option allows the easy intermixing of library functions (used via the 
305 .B \-f
306 and
307 .B \-\^\-file
308 options) with source code entered on the command line.
309 It is intended primarily for medium to large AWK programs used
310 in shell scripts.
311 .TP
312 .PD 0
313 .B "\-W version"
314 .TP
315 .PD
316 .B \-\^\-version
317 Print version information for this particular copy of
318 .I gawk
319 on the standard output.
320 This is useful mainly for knowing if the current copy of
321 .I gawk
322 on your system
323 is up to date with respect to whatever the Free Software Foundation
324 is distributing.
325 This is also useful when reporting bugs.
326 (Per the
327 .IR "GNU Coding Standards" ,
328 these options cause an immediate, successful exit.)
329 .TP
330 .B \-\^\-
331 Signal the end of options. This is useful to allow further arguments to the
332 AWK program itself to start with a ``\-''.
333 This is mainly for consistency with the argument parsing convention used
334 by most other \*(PX programs.
335 .PP
336 In compatibility mode,
337 any other options are flagged as illegal, but are otherwise ignored.
338 In normal operation, as long as program text has been supplied, unknown
339 options are passed on to the AWK program in the
340 .B ARGV
341 array for processing.  This is particularly useful for running AWK
342 programs via the ``#!'' executable interpreter mechanism.
343 .SH AWK PROGRAM EXECUTION
344 .PP
345 An AWK program consists of a sequence of pattern-action statements
346 and optional function definitions.
347 .RS
348 .PP
349 \fIpattern\fB   { \fIaction statements\fB }\fR
350 .br
351 \fBfunction \fIname\fB(\fIparameter list\fB) { \fIstatements\fB }\fR
352 .RE
353 .PP
354 .I Gawk
355 first reads the program source from the
356 .IR program-file (s)
357 if specified,
358 from arguments to
359 .BR \-\^\-source ,
360 or from the first non-option argument on the command line.
361 The
362 .B \-f
363 and
364 .B \-\^\-source
365 options may be used multiple times on the command line.
366 .I Gawk
367 will read the program text as if all the
368 .IR program-file s
369 and command line source texts
370 had been concatenated together.  This is useful for building libraries
371 of AWK functions, without having to include them in each new AWK
372 program that uses them.  It also provides the ability to mix library
373 functions with command line programs.
374 .PP
375 The environment variable
376 .B AWKPATH
377 specifies a search path to use when finding source files named with
378 the 
379 .B \-f
380 option.  If this variable does not exist, the default path is
381 \fB".:/usr/local/share/awk"\fR.
382 (The actual directory may vary, depending upon how
383 .I gawk
384 was built and installed.)
385 If a file name given to the
386 .B \-f
387 option contains a ``/'' character, no path search is performed.
388 .PP
389 .I Gawk
390 executes AWK programs in the following order.
391 First,
392 all variable assignments specified via the
393 .B \-v
394 option are performed.
395 Next,
396 .I gawk
397 compiles the program into an internal form.
398 Then,
399 .I gawk
400 executes the code in the
401 .B BEGIN
402 block(s) (if any),
403 and then proceeds to read
404 each file named in the
405 .B ARGV
406 array.
407 If there are no files named on the command line,
408 .I gawk
409 reads the standard input.
410 .PP
411 If a filename on the command line has the form
412 .IB var = val
413 it is treated as a variable assignment. The variable
414 .I var
415 will be assigned the value
416 .IR val .
417 (This happens after any
418 .B BEGIN
419 block(s) have been run.)
420 Command line variable assignment
421 is most useful for dynamically assigning values to the variables
422 AWK uses to control how input is broken into fields and records. It
423 is also useful for controlling state if multiple passes are needed over
424 a single data file.
425 .PP
426 If the value of a particular element of
427 .B ARGV
428 is empty (\fB""\fR),
429 .I gawk
430 skips over it.
431 .PP
432 For each record in the input,
433 .I gawk
434 tests to see if it matches any
435 .I pattern
436 in the AWK program.
437 For each pattern that the record matches, the associated
438 .I action
439 is executed.
440 The patterns are tested in the order they occur in the program.
441 .PP
442 Finally, after all the input is exhausted,
443 .I gawk
444 executes the code in the
445 .B END
446 block(s) (if any).
447 .SH VARIABLES, RECORDS AND FIELDS
448 AWK variables are dynamic; they come into existence when they are
449 first used. Their values are either floating-point numbers or strings,
450 or both,
451 depending upon how they are used. AWK also has one dimensional
452 arrays; arrays with multiple dimensions may be simulated.
453 Several pre-defined variables are set as a program
454 runs; these will be described as needed and summarized below.
455 .SS Records
456 Normally, records are separated by newline characters. You can control how
457 records are separated by assigning values to the built-in variable
458 .BR RS .
459 If 
460 .B RS
461 is any single character, that character separates records.
462 Otherwise,
463 .B RS
464 is a regular expression.  Text in the input that matches this
465 regular expression will separate the record.
466 However, in compatibility mode,
467 only the first character of its string
468 value is used for separating records.
469 If
470 .B RS
471 is set to the null string, then records are separated by
472 blank lines.
473 When
474 .B RS
475 is set to the null string, the newline character always acts as
476 a field separator, in addition to whatever value
477 .B FS
478 may have.
479 .SS Fields
480 .PP
481 As each input record is read,
482 .I gawk
483 splits the record into
484 .IR fields ,
485 using the value of the
486 .B FS
487 variable as the field separator.
488 If
489 .B FS
490 is a single character, fields are separated by that character.
491 If
492 .B FS
493 is the null string, then each individual character becomes a
494 separate field.
495 Otherwise,
496 .B FS
497 is expected to be a full regular expression.
498 In the special case that
499 .B FS
500 is a single space, fields are separated
501 by runs of spaces and/or tabs and/or newlines.
502 (But see the discussion of
503 .BR \-\-posix ,
504 below).
505 Note that the value of
506 .B IGNORECASE
507 (see below) will also affect how fields are split when
508 .B FS
509 is a regular expression, and how records are separated when
510 .B RS
511 is a regular expression.
512 .PP
513 If the
514 .B FIELDWIDTHS
515 variable is set to a space separated list of numbers, each field is
516 expected to have fixed width, and
517 .I gawk
518 will split up the record using the specified widths.  The value of
519 .B FS
520 is ignored.
521 Assigning a new value to
522 .B FS
523 overrides the use of
524 .BR FIELDWIDTHS ,
525 and restores the default behavior.
526 .PP
527 Each field in the input record may be referenced by its position,
528 .BR $1 ,
529 .BR $2 ,
530 and so on.
531 .B $0
532 is the whole record. The value of a field may be assigned to as well.
533 Fields need not be referenced by constants:
534 .RS
535 .PP
536 .ft B
537 n = 5
538 .br
539 print $n
540 .ft R
541 .RE
542 .PP
543 prints the fifth field in the input record.
544 The variable
545 .B NF
546 is set to the total number of fields in the input record.
547 .PP
548 References to non-existent fields (i.e. fields after
549 .BR $NF )
550 produce the null-string. However, assigning to a non-existent field
551 (e.g., 
552 .BR "$(NF+2) = 5" )
553 will increase the value of
554 .BR NF ,
555 create any intervening fields with the null string as their value, and
556 cause the value of
557 .B $0
558 to be recomputed, with the fields being separated by the value of
559 .BR OFS .
560 References to negative numbered fields cause a fatal error.
561 Decrementing
562 .B NF
563 causes the values of fields past the new value to be lost, and the value of
564 .B $0
565 to be recomputed, with the fields being separated by the value of
566 .BR OFS .
567 .SS Built-in Variables
568 .PP
569 .IR Gawk 's
570 built-in variables are:
571 .PP
572 .TP \w'\fBFIELDWIDTHS\fR'u+1n
573 .B ARGC
574 The number of command line arguments (does not include options to
575 .IR gawk ,
576 or the program source).
577 .TP
578 .B ARGIND
579 The index in
580 .B ARGV
581 of the current file being processed.
582 .TP
583 .B ARGV
584 Array of command line arguments. The array is indexed from
585 0 to
586 .B ARGC
587 \- 1.
588 Dynamically changing the contents of
589 .B ARGV
590 can control the files used for data.
591 .TP
592 .B CONVFMT
593 The conversion format for numbers, \fB"%.6g"\fR, by default.
594 .TP
595 .B ENVIRON
596 An array containing the values of the current environment.
597 The array is indexed by the environment variables, each element being
598 the value of that variable (e.g., \fBENVIRON["HOME"]\fP might be
599 .BR /home/arnold ).
600 Changing this array does not affect the environment seen by programs which
601 .I gawk
602 spawns via redirection or the
603 .B system()
604 function.
605 (This may change in a future version of
606 .IR gawk .)
607 .\" but don't hold your breath...
608 .TP
609 .B ERRNO
610 If a system error occurs either doing a redirection for
611 .BR getline ,
612 during a read for
613 .BR getline ,
614 or during a
615 .BR close() ,
616 then
617 .B ERRNO
618 will contain
619 a string describing the error.
620 .TP
621 .B FIELDWIDTHS
622 A white-space separated list of fieldwidths.  When set,
623 .I gawk
624 parses the input into fields of fixed width, instead of using the
625 value of the
626 .B FS
627 variable as the field separator.
628 The fixed field width facility is still experimental; the
629 semantics may change as
630 .I gawk
631 evolves over time.
632 .TP
633 .B FILENAME
634 The name of the current input file.
635 If no files are specified on the command line, the value of
636 .B FILENAME
637 is ``\-''.
638 However,
639 .B FILENAME
640 is undefined inside the
641 .B BEGIN
642 block.
643 .TP
644 .B FNR
645 The input record number in the current input file.
646 .TP
647 .B FS
648 The input field separator, a space by default.  See
649 .BR Fields ,
650 above.
651 .TP
652 .B IGNORECASE
653 Controls the case-sensitivity of all regular expression 
654 and string operations. If
655 .B IGNORECASE
656 has a non-zero value, then string comparisons and
657 pattern matching in rules,
658 field splitting with
659 .BR FS ,
660 record separating with
661 .BR RS ,
662 regular expression
663 matching with
664 .B ~
665 and
666 .BR !~ ,
667 and the
668 .BR gensub() ,
669 .BR gsub() ,
670 .BR index() ,
671 .BR match() ,
672 .BR split() ,
673 and
674 .B sub()
675 pre-defined functions will all ignore case when doing regular expression
676 operations.  Thus, if
677 .B IGNORECASE
678 is not equal to zero,
679 .B /aB/
680 matches all of the strings \fB"ab"\fP, \fB"aB"\fP, \fB"Ab"\fP,
681 and \fB"AB"\fP.
682 As with all AWK variables, the initial value of
683 .B IGNORECASE
684 is zero, so all regular expression and string
685 operations are normally case-sensitive.
686 Under Unix, the full ISO 8859-1 Latin-1 character set is used
687 when ignoring case.
688 .B NOTE:
689 In versions of
690 .I gawk
691 prior to 3.0,
692 .B IGNORECASE
693 only affected regular expression operations. It now affects string
694 comparisons as well.
695 .TP
696 .B NF
697 The number of fields in the current input record.
698 .TP
699 .B NR
700 The total number of input records seen so far.
701 .TP
702 .B OFMT
703 The output format for numbers, \fB"%.6g"\fR, by default.
704 .TP
705 .B OFS
706 The output field separator, a space by default.
707 .TP
708 .B ORS
709 The output record separator, by default a newline.
710 .TP
711 .B RS
712 The input record separator, by default a newline.
713 .TP
714 .B RT
715 The record terminator.
716 .I Gawk
717 sets
718 .B RT
719 to the input text that matched the character or regular expression
720 specified by
721 .BR RS .
722 .TP
723 .B RSTART
724 The index of the first character matched by
725 .BR match() ;
726 0 if no match.
727 .TP
728 .B RLENGTH
729 The length of the string matched by
730 .BR match() ;
731 \-1 if no match.
732 .TP
733 .B SUBSEP
734 The character used to separate multiple subscripts in array
735 elements, by default \fB"\e034"\fR.
736 .SS Arrays
737 .PP
738 Arrays are subscripted with an expression between square brackets
739 .RB ( [ " and " ] ).
740 If the expression is an expression list
741 .RI ( expr ", " expr " ...)"
742 then the array subscript is a string consisting of the
743 concatenation of the (string) value of each expression,
744 separated by the value of the
745 .B SUBSEP
746 variable.
747 This facility is used to simulate multiply dimensioned
748 arrays. For example:
749 .PP
750 .RS
751 .ft B
752 i = "A";\^ j = "B";\^ k = "C"
753 .br
754 x[i, j, k] = "hello, world\en"
755 .ft R
756 .RE
757 .PP
758 assigns the string \fB"hello, world\en"\fR to the element of the array
759 .B x
760 which is indexed by the string \fB"A\e034B\e034C"\fR. All arrays in AWK
761 are associative, i.e. indexed by string values.
762 .PP
763 The special operator
764 .B in
765 may be used in an
766 .B if
767 or
768 .B while
769 statement to see if an array has an index consisting of a particular
770 value.
771 .PP
772 .RS
773 .ft B
774 .nf
775 if (val in array)
776         print array[val]
777 .fi
778 .ft
779 .RE
780 .PP
781 If the array has multiple subscripts, use
782 .BR "(i, j) in array" .
783 .PP
784 The
785 .B in
786 construct may also be used in a
787 .B for
788 loop to iterate over all the elements of an array.
789 .PP
790 An element may be deleted from an array using the
791 .B delete
792 statement.
793 The
794 .B delete
795 statement may also be used to delete the entire contents of an array,
796 just by specifying the array name without a subscript.
797 .SS Variable Typing And Conversion
798 .PP
799 Variables and fields
800 may be (floating point) numbers, or strings, or both. How the
801 value of a variable is interpreted depends upon its context. If used in
802 a numeric expression, it will be treated as a number, if used as a string
803 it will be treated as a string.
804 .PP
805 To force a variable to be treated as a number, add 0 to it; to force it
806 to be treated as a string, concatenate it with the null string.
807 .PP
808 When a string must be converted to a number, the conversion is accomplished
809 using
810 .IR atof (3).
811 A number is converted to a string by using the value of
812 .B CONVFMT
813 as a format string for
814 .IR sprintf (3),
815 with the numeric value of the variable as the argument.
816 However, even though all numbers in AWK are floating-point,
817 integral values are
818 .I always
819 converted as integers.  Thus, given
820 .PP
821 .RS
822 .ft B
823 .nf
824 CONVFMT = "%2.2f"
825 a = 12
826 b = a ""
827 .fi
828 .ft R
829 .RE
830 .PP
831 the variable
832 .B b
833 has a string value of \fB"12"\fR and not \fB"12.00"\fR.
834 .PP
835 .I Gawk
836 performs comparisons as follows:
837 If two variables are numeric, they are compared numerically.
838 If one value is numeric and the other has a string value that is a
839 ``numeric string,'' then comparisons are also done numerically.
840 Otherwise, the numeric value is converted to a string and a string
841 comparison is performed.
842 Two strings are compared, of course, as strings.
843 According to the \*(PX standard, even if two strings are
844 numeric strings, a numeric comparison is performed.  However, this is
845 clearly incorrect, and
846 .I gawk
847 does not do this.
848 .PP
849 Note that string constants, such as \fB"57"\fP, are
850 .I not
851 numeric strings, they are string constants.  The idea of ``numeric string''
852 only applies to fields,
853 .B getline
854 input,
855 .BR FILENAME ,
856 .B ARGV
857 elements,
858 .B ENVIRON
859 elements and the elements of an array created by
860 .B split()
861 that are numeric strings.
862 The basic idea is that
863 .IR "user input" ,
864 and only user input, that looks numeric,
865 should be treated that way.
866 .PP
867 Uninitialized variables have the numeric value 0 and the string value ""
868 (the null, or empty, string).
869 .SH PATTERNS AND ACTIONS
870 AWK is a line oriented language. The pattern comes first, and then the
871 action. Action statements are enclosed in
872 .B {
873 and
874 .BR } .
875 Either the pattern may be missing, or the action may be missing, but,
876 of course, not both. If the pattern is missing, the action will be
877 executed for every single record of input.
878 A missing action is equivalent to
879 .RS
880 .PP
881 .B "{ print }"
882 .RE
883 .PP
884 which prints the entire record.
885 .PP
886 Comments begin with the ``#'' character, and continue until the
887 end of the line.
888 Blank lines may be used to separate statements.
889 Normally, a statement ends with a newline, however, this is not the
890 case for lines ending in
891 a ``,'',
892 .BR { ,
893 .BR ? ,
894 .BR : ,
895 .BR && ,
896 or
897 .BR || .
898 Lines ending in
899 .B do
900 or
901 .B else
902 also have their statements automatically continued on the following line.
903 In other cases, a line can be continued by ending it with a ``\e'',
904 in which case the newline will be ignored.
905 .PP
906 Multiple statements may
907 be put on one line by separating them with a ``;''.
908 This applies to both the statements within the action part of a
909 pattern-action pair (the usual case),
910 and to the pattern-action statements themselves.
911 .SS Patterns
912 AWK patterns may be one of the following:
913 .PP
914 .RS
915 .nf
916 .B BEGIN
917 .B END
918 .BI / "regular expression" /
919 .I "relational expression"
920 .IB pattern " && " pattern
921 .IB pattern " || " pattern
922 .IB pattern " ? " pattern " : " pattern
923 .BI ( pattern )
924 .BI ! " pattern"
925 .IB pattern1 ", " pattern2
926 .fi
927 .RE
928 .PP
929 .B BEGIN
930 and
931 .B END
932 are two special kinds of patterns which are not tested against
933 the input.
934 The action parts of all
935 .B BEGIN
936 patterns are merged as if all the statements had
937 been written in a single
938 .B BEGIN
939 block. They are executed before any
940 of the input is read. Similarly, all the
941 .B END
942 blocks are merged,
943 and executed when all the input is exhausted (or when an
944 .B exit
945 statement is executed).
946 .B BEGIN
947 and
948 .B END
949 patterns cannot be combined with other patterns in pattern expressions.
950 .B BEGIN
951 and
952 .B END
953 patterns cannot have missing action parts.
954 .PP
955 For
956 .BI / "regular expression" /
957 patterns, the associated statement is executed for each input record that matches
958 the regular expression.
959 Regular expressions are the same as those in
960 .IR egrep (1),
961 and are summarized below.
962 .PP
963 A
964 .I "relational expression"
965 may use any of the operators defined below in the section on actions.
966 These generally test whether certain fields match certain regular expressions.
967 .PP
968 The
969 .BR && ,
970 .BR || ,
971 and
972 .B !
973 operators are logical AND, logical OR, and logical NOT, respectively, as in C.
974 They do short-circuit evaluation, also as in C, and are used for combining
975 more primitive pattern expressions. As in most languages, parentheses
976 may be used to change the order of evaluation.
977 .PP
978 The
979 .B ?\^:
980 operator is like the same operator in C. If the first pattern is true
981 then the pattern used for testing is the second pattern, otherwise it is
982 the third. Only one of the second and third patterns is evaluated.
983 .PP
984 The 
985 .IB pattern1 ", " pattern2
986 form of an expression is called a
987 .IR "range pattern" .
988 It matches all input records starting with a record that matches
989 .IR pattern1 ,
990 and continuing until a record that matches
991 .IR pattern2 ,
992 inclusive. It does not combine with any other sort of pattern expression.
993 .SS Regular Expressions
994 Regular expressions are the extended kind found in
995 .IR egrep .
996 They are composed of characters as follows:
997 .TP \w'\fB[^\fIabc...\fB]\fR'u+2n
998 .I c
999 matches the non-metacharacter
1000 .IR c .
1001 .TP
1002 .I \ec
1003 matches the literal character
1004 .IR c .
1005 .TP
1006 .B .
1007 matches any character
1008 .I including
1009 newline.
1010 .TP
1011 .B ^
1012 matches the beginning of a string.
1013 .TP
1014 .B $
1015 matches the end of a string.
1016 .TP
1017 .BI [ abc... ]
1018 character list, matches any of the characters
1019 .IR abc... .
1020 .TP
1021 .BI [^ abc... ]
1022 negated character list, matches any character except
1023 .IR abc... .
1024 .TP
1025 .IB r1 | r2
1026 alternation: matches either
1027 .I r1
1028 or
1029 .IR r2 .
1030 .TP
1031 .I r1r2
1032 concatenation: matches
1033 .IR r1 ,
1034 and then
1035 .IR r2 .
1036 .TP
1037 .IB r +
1038 matches one or more
1039 .IR r 's. 
1040 .TP
1041 .IB r *
1042 matches zero or more
1043 .IR r 's. 
1044 .TP
1045 .IB r ?
1046 matches zero or one
1047 .IR r 's. 
1048 .TP
1049 .BI ( r )
1050 grouping: matches
1051 .IR r .
1052 .TP
1053 .PD 0
1054 .IB r { n }
1055 .TP
1056 .PD 0
1057 .IB r { n ,}
1058 .TP
1059 .PD
1060 .IB r { n , m }
1061 One or two numbers inside braces denote an
1062 .IR "interval expression" .
1063 If there is one number in the braces, the preceding regexp
1064 .I r
1065 is repeated
1066 .I n
1067 times.  If there are two numbers separated by a comma,
1068 .I r
1069 is repeated
1070 .I n
1071 to
1072 .I m
1073 times.
1074 If there is one number followed by a comma, then
1075 .I r
1076 is repeated at least
1077 .I n
1078 times.
1079 .sp .5
1080 Interval expressions are only available if either
1081 .B \-\^\-posix
1082 or
1083 .B \-\^\-re\-interval
1084 is specified on the command line.
1085 .TP
1086 .B \ey
1087 matches the empty string at either the beginning or the
1088 end of a word.
1089 .TP
1090 .B \eB
1091 matches the empty string within a word.
1092 .TP
1093 .B \e<
1094 matches the empty string at the beginning of a word.
1095 .TP
1096 .B \e>
1097 matches the empty string at the end of a word.
1098 .TP
1099 .B \ew
1100 matches any word-constituent character (letter, digit, or underscore).
1101 .TP
1102 .B \eW
1103 matches any character that is not word-constituent.
1104 .TP
1105 .B \e`
1106 matches the empty string at the beginning of a buffer (string).
1107 .TP
1108 .B \e'
1109 matches the empty string at the end of a buffer.
1110 .PP
1111 The escape sequences that are valid in string constants (see below)
1112 are also legal in regular expressions.
1113 .PP
1114 .I "Character classes"
1115 are a new feature introduced in the POSIX standard.
1116 A character class is a special notation for describing
1117 lists of characters that have a specific attribute, but where the 
1118 actual characters themselves can vary from country to country and/or
1119 from character set to character set.  For example, the notion of what
1120 is an alphabetic character differs in the USA and in France.
1121 .PP
1122 A character class is only valid in a regexp
1123 .I inside
1124 the brackets of a character list.  Character classes consist of
1125 .BR [: ,
1126 a keyword denoting the class, and
1127 .BR :] .
1128 Here are the character
1129 classes defined by the POSIX standard.
1130 .TP
1131 .B [:alnum:]
1132 Alphanumeric characters.
1133 .TP
1134 .B [:alpha:]
1135 Alphabetic characters.
1136 .TP
1137 .B [:blank:]
1138 Space or tab characters.
1139 .TP
1140 .B [:cntrl:]
1141 Control characters.
1142 .TP
1143 .B [:digit:]
1144 Numeric characters.
1145 .TP
1146 .B [:graph:]
1147 Characters that are both printable and visible.
1148 (A space is printable, but not visible, while an
1149 .B a
1150 is both.)
1151 .TP
1152 .B [:lower:]
1153 Lower-case alphabetic characters.
1154 .TP
1155 .B [:print:]
1156 Printable characters (characters that are not control characters.)
1157 .TP
1158 .B [:punct:]
1159 Punctuation characters (characters that are not letter, digits,
1160 control characters, or space characters).
1161 .TP
1162 .B [:space:]
1163 Space characters (such as space, tab, and formfeed, to name a few).
1164 .TP
1165 .B [:upper:]
1166 Upper-case alphabetic characters.
1167 .TP
1168 .B [:xdigit:]
1169 Characters that are hexadecimal digits.
1170 .PP
1171 For example, before the POSIX standard, to match alphanumeric
1172 characters, you would have had to write
1173 .BR /[A\-Za\-z0\-9]/ .
1174 If your character set had other alphabetic characters in it, this would not
1175 match them.  With the POSIX character classes, you can write
1176 .BR /[[:alnum:]]/ ,
1177 and this will match
1178 .I all
1179 the alphabetic and numeric characters in your character set.
1180 .PP
1181 Two additional special sequences can appear in character lists.
1182 These apply to non-ASCII character sets, which can have single symbols
1183 (called 
1184 .IR "collating elements" )
1185 that are represented with more than one
1186 character, as well as several characters that are equivalent for
1187 .IR collating ,
1188 or sorting, purposes.  (E.g., in French, a plain ``e''
1189 and a grave-accented e\` are equivalent.)
1190 .TP
1191 Collating Symbols
1192 A collating symbols is a multi-character collating element enclosed in
1193 .B [.
1194 and
1195 .BR .] .
1196 For example, if
1197 .B ch
1198 is a collating element, then
1199 .B [[.ch.]]
1200 is a regexp that matches this collating element, while
1201 .B [ch]
1202 is a regexp that matches either
1203 .B c
1204 or
1205 .BR h .
1206 .TP
1207 Equivalence Classes
1208 An equivalence class is a locale-specific name for a list of
1209 characters that are equivalent. The name is enclosed in
1210 .B [=
1211 and
1212 .BR =] .
1213 For example, the name
1214 .B e
1215 might be used to represent all of
1216 ``e,'' ``e\`,'' and ``e\`.''
1217 In this case,
1218 .B [[=e=]]
1219 is a regexp
1220 that matches any of
1221 .BR e ,
1222 .BR e\' ,
1223 or
1224 .BR e\` .
1225 .PP
1226 These features are very valuable in non-English speaking locales.
1227 The library functions that
1228 .I gawk
1229 uses for regular expression matching
1230 currently only recognize POSIX character classes; they do not recognize
1231 collating symbols or equivalence classes.
1232 .PP
1233 The
1234 .BR \ey ,
1235 .BR \eB ,
1236 .BR \e< ,
1237 .BR \e> ,
1238 .BR \ew ,
1239 .BR \eW ,
1240 .BR \e` ,
1241 and
1242 .B \e'
1243 operators are specific to
1244 .IR gawk ;
1245 they are extensions based on facilities in the GNU regexp libraries.
1246 .PP
1247 The various command line options
1248 control how
1249 .I gawk
1250 interprets characters in regexps.
1251 .TP
1252 No options
1253 In the default case,
1254 .I gawk
1255 provide all the facilities of
1256 POSIX regexps and the GNU regexp operators described above.
1257 However, interval expressions are not supported.
1258 .TP
1259 .B \-\^\-posix
1260 Only POSIX regexps are supported, the GNU operators are not special.
1261 (E.g.,
1262 .B \ew
1263 matches a literal
1264 .BR w ).
1265 Interval expressions are allowed.
1266 .TP
1267 .B \-\^\-traditional
1268 Traditional Unix
1269 .I awk
1270 regexps are matched. The GNU operators
1271 are not special, interval expressions are not available, and neither
1272 are the POSIX character classes
1273 .RB ( [[:alnum:]]
1274 and so on).
1275 Characters described by octal and hexadecimal escape sequences are
1276 treated literally, even if they represent regexp metacharacters.
1277 .TP
1278 .B \-\^\-re\-interval
1279 Allow interval expressions in regexps, even if
1280 .B \-\^\-traditional
1281 has been provided.
1282 .SS Actions
1283 Action statements are enclosed in braces,
1284 .B {
1285 and
1286 .BR } .
1287 Action statements consist of the usual assignment, conditional, and looping
1288 statements found in most languages. The operators, control statements,
1289 and input/output statements
1290 available are patterned after those in C.
1291 .SS Operators
1292 .PP
1293 The operators in AWK, in order of decreasing precedence, are
1294 .PP
1295 .TP "\w'\fB*= /= %= ^=\fR'u+1n"
1296 .BR ( \&... )
1297 Grouping
1298 .TP
1299 .B $
1300 Field reference.
1301 .TP
1302 .B "++ \-\^\-"
1303 Increment and decrement, both prefix and postfix.
1304 .TP
1305 .B ^
1306 Exponentiation (\fB**\fR may also be used, and \fB**=\fR for
1307 the assignment operator).
1308 .TP
1309 .B "+ \- !"
1310 Unary plus, unary minus, and logical negation.
1311 .TP
1312 .B "* / %"
1313 Multiplication, division, and modulus.
1314 .TP
1315 .B "+ \-"
1316 Addition and subtraction.
1317 .TP
1318 .I space
1319 String concatenation.
1320 .TP
1321 .PD 0
1322 .B "< >"
1323 .TP
1324 .PD 0
1325 .B "<= >="
1326 .TP
1327 .PD
1328 .B "!= =="
1329 The regular relational operators.
1330 .TP
1331 .B "~ !~"
1332 Regular expression match, negated match.
1333 .B NOTE:
1334 Do not use a constant regular expression
1335 .RB ( /foo/ )
1336 on the left-hand side of a
1337 .B ~
1338 or
1339 .BR !~ .
1340 Only use one on the right-hand side.  The expression
1341 .BI "/foo/ ~ " exp
1342 has the same meaning as \fB(($0 ~ /foo/) ~ \fIexp\fB)\fR.
1343 This is usually
1344 .I not
1345 what was intended.
1346 .TP
1347 .B in
1348 Array membership.
1349 .TP
1350 .B &&
1351 Logical AND.
1352 .TP
1353 .B ||
1354 Logical OR.
1355 .TP
1356 .B ?:
1357 The C conditional expression. This has the form
1358 .IB expr1 " ? " expr2 " : " expr3\c
1359 \&. If
1360 .I expr1
1361 is true, the value of the expression is
1362 .IR expr2 ,
1363 otherwise it is
1364 .IR expr3 .
1365 Only one of
1366 .I expr2
1367 and
1368 .I expr3
1369 is evaluated.
1370 .TP
1371 .PD 0
1372 .B "= += \-="
1373 .TP
1374 .PD
1375 .B "*= /= %= ^="
1376 Assignment. Both absolute assignment
1377 .BI ( var " = " value )
1378 and operator-assignment (the other forms) are supported.
1379 .SS Control Statements
1380 .PP
1381 The control statements are
1382 as follows:
1383 .PP
1384 .RS
1385 .nf
1386 \fBif (\fIcondition\fB) \fIstatement\fR [ \fBelse\fI statement \fR]
1387 \fBwhile (\fIcondition\fB) \fIstatement \fR
1388 \fBdo \fIstatement \fBwhile (\fIcondition\fB)\fR
1389 \fBfor (\fIexpr1\fB; \fIexpr2\fB; \fIexpr3\fB) \fIstatement\fR
1390 \fBfor (\fIvar \fBin\fI array\fB) \fIstatement\fR
1391 \fBbreak\fR
1392 \fBcontinue\fR
1393 \fBdelete \fIarray\^\fB[\^\fIindex\^\fB]\fR
1394 \fBdelete \fIarray\^\fR
1395 \fBexit\fR [ \fIexpression\fR ]
1396 \fB{ \fIstatements \fB}
1397 .fi
1398 .RE
1399 .SS "I/O Statements"
1400 .PP
1401 The input/output statements are as follows:
1402 .PP
1403 .TP "\w'\fBprintf \fIfmt, expr-list\fR'u+1n"
1404 .BI close( file )
1405 Close file (or pipe, see below).
1406 .TP
1407 .B getline
1408 Set
1409 .B $0
1410 from next input record; set
1411 .BR NF ,
1412 .BR NR ,
1413 .BR FNR .
1414 .TP
1415 .BI "getline <" file
1416 Set
1417 .B $0
1418 from next record of
1419 .IR file ;
1420 set
1421 .BR NF .
1422 .TP
1423 .BI getline " var"
1424 Set
1425 .I var
1426 from next input record; set
1427 .BR NR ,
1428 .BR FNR .
1429 .TP
1430 .BI getline " var" " <" file
1431 Set
1432 .I var
1433 from next record of
1434 .IR file .
1435 .TP
1436 .B next
1437 Stop processing the current input record. The next input record
1438 is read and processing starts over with the first pattern in the
1439 AWK program. If the end of the input data is reached, the
1440 .B END
1441 block(s), if any, are executed.
1442 .TP
1443 .B "nextfile"
1444 Stop processing the current input file.  The next input record read
1445 comes from the next input file.
1446 .B FILENAME
1447 and
1448 .B ARGIND
1449 are updated,
1450 .B FNR
1451 is reset to 1, and processing starts over with the first pattern in the
1452 AWK program. If the end of the input data is reached, the
1453 .B END
1454 block(s), if any, are executed.
1455 .B NOTE:
1456 Earlier versions of gawk used
1457 .BR "next file" ,
1458 as two words. While this usage is still recognized, it generates a
1459 warning message and will eventually be removed.
1460 .TP
1461 .B print
1462 Prints the current record.
1463 The output record is terminated with the value of the
1464 .B ORS
1465 variable.
1466 .TP
1467 .BI print " expr-list"
1468 Prints expressions.
1469 Each expression is separated by the value of the
1470 .B OFS
1471 variable.
1472 The output record is terminated with the value of the
1473 .B ORS
1474 variable.
1475 .TP
1476 .BI print " expr-list" " >" file
1477 Prints expressions on
1478 .IR file .
1479 Each expression is separated by the value of the
1480 .B OFS
1481 variable. The output record is terminated with the value of the
1482 .B ORS
1483 variable.
1484 .TP
1485 .BI printf " fmt, expr-list"
1486 Format and print.
1487 .TP
1488 .BI printf " fmt, expr-list" " >" file
1489 Format and print on
1490 .IR file .
1491 .TP
1492 .BI system( cmd-line )
1493 Execute the command
1494 .IR cmd-line ,
1495 and return the exit status.
1496 (This may not be available on non-\*(PX systems.)
1497 .TP
1498 \&\fBfflush(\fR[\fIfile\^\fR]\fB)\fR
1499 Flush any buffers associated with the open output file or pipe
1500 .IR file .
1501 If
1502 .I file
1503 is missing, then standard output is flushed.
1504 If
1505 .I file
1506 is the null string,
1507 then all open output files and pipes
1508 have their buffers flushed.
1509 .PP
1510 Other input/output redirections are also allowed. For
1511 .B print
1512 and
1513 .BR printf ,
1514 .BI >> file
1515 appends output to the
1516 .IR file ,
1517 while
1518 .BI | " command"
1519 writes on a pipe.
1520 In a similar fashion,
1521 .IB command " | getline"
1522 pipes into
1523 .BR getline .
1524 The
1525 .BR getline
1526 command will return 0 on end of file, and \-1 on an error.
1527 .SS The \fIprintf\fP\^ Statement
1528 .PP
1529 The AWK versions of the
1530 .B printf
1531 statement and
1532 .B sprintf()
1533 function
1534 (see below)
1535 accept the following conversion specification formats:
1536 .TP
1537 .B %c
1538 An \s-1ASCII\s+1 character.
1539 If the argument used for
1540 .B %c
1541 is numeric, it is treated as a character and printed.
1542 Otherwise, the argument is assumed to be a string, and the only first
1543 character of that string is printed.
1544 .TP
1545 .PD 0
1546 .B %d
1547 .TP
1548 .PD
1549 .B %i
1550 A decimal number (the integer part).
1551 .TP
1552 .PD 0
1553 .B %e
1554 .TP
1555 .PD
1556 .B %E
1557 A floating point number of the form
1558 .BR [\-]d.dddddde[+\^\-]dd .
1559 The
1560 .B %E
1561 format uses
1562 .B E
1563 instead of
1564 .BR e .
1565 .TP
1566 .B %f
1567 A floating point number of the form
1568 .BR [\-]ddd.dddddd .
1569 .TP
1570 .PD 0
1571 .B %g
1572 .TP
1573 .PD
1574 .B %G
1575 Use
1576 .B %e
1577 or
1578 .B %f
1579 conversion, whichever is shorter, with nonsignificant zeros suppressed.
1580 The
1581 .B %G
1582 format uses
1583 .B %E
1584 instead of
1585 .BR %e .
1586 .TP
1587 .B %o
1588 An unsigned octal number (again, an integer).
1589 .TP
1590 .B %s
1591 A character string.
1592 .TP
1593 .PD 0
1594 .B %x
1595 .TP
1596 .PD
1597 .B %X
1598 An unsigned hexadecimal number (an integer).
1599 .The
1600 .B %X
1601 format uses
1602 .B ABCDEF
1603 instead of
1604 .BR abcdef .
1605 .TP
1606 .B %%
1607 A single
1608 .B %
1609 character; no argument is converted.
1610 .PP
1611 There are optional, additional parameters that may lie between the
1612 .B %
1613 and the control letter:
1614 .TP
1615 .B \-
1616 The expression should be left-justified within its field.
1617 .TP
1618 .I space
1619 For numeric conversions, prefix positive values with a space, and
1620 negative values with a minus sign.
1621 .TP
1622 .B +
1623 The plus sign, used before the width modifier (see below),
1624 says to always supply a sign for numeric conversions, even if the data
1625 to be formatted is positive. The
1626 .B +
1627 overrides the space modifier.
1628 .TP
1629 .B #
1630 Use an ``alternate form'' for certain control letters.
1631 For
1632 .BR %o ,
1633 supply a leading zero.
1634 For
1635 .BR %x ,
1636 and
1637 .BR %X ,
1638 supply a leading
1639 .BR 0x 
1640 or
1641 .BR 0X 
1642 for
1643 a nonzero result.
1644 For
1645 .BR %e ,
1646 .BR %E ,
1647 and
1648 .BR %f ,
1649 the result will always contain a
1650 decimal point.
1651 For
1652 .BR %g ,
1653 and
1654 .BR %G ,
1655 trailing zeros are not removed from the result.
1656 .TP
1657 .B 0
1658 A leading
1659 .B 0
1660 (zero) acts as a flag, that indicates output should be
1661 padded with zeroes instead of spaces.
1662 This applies even to non-numeric output formats.
1663 This flag only has an effect when the field width is wider than the
1664 value to be printed.
1665 .TP
1666 .I width
1667 The field should be padded to this width. The field is normally padded
1668 with spaces.  If the
1669 .B 0
1670 flag has been used, it is padded with zeroes.
1671 .TP
1672 .BI \&. prec
1673 A number that specifies the precision to use when printing.
1674 For the
1675 .BR %e ,
1676 .BR %E ,
1677 and
1678 .BR %f 
1679 formats, this specifies the
1680 number of digits you want printed to the right of the decimal point.
1681 For the
1682 .BR %g ,
1683 and
1684 .B %G
1685 formats, it specifies the maximum number
1686 of significant digits.  For the
1687 .BR %d ,
1688 .BR %o ,
1689 .BR %i ,
1690 .BR %u ,
1691 .BR %x ,
1692 and
1693 .B %X
1694 formats, it specifies the minimum number of
1695 digits to print.  For a string, it specifies the maximum number of
1696 characters from the string that should be printed.
1697 .PP
1698 The dynamic
1699 .I width
1700 and
1701 .I prec
1702 capabilities of the \*(AN C
1703 .B printf()
1704 routines are supported.
1705 A
1706 .B *
1707 in place of either the
1708 .B width
1709 or
1710 .B prec
1711 specifications will cause their values to be taken from
1712 the argument list to
1713 .B printf
1714 or
1715 .BR sprintf() .
1716 .SS Special File Names
1717 .PP
1718 When doing I/O redirection from either
1719 .B print
1720 or
1721 .B printf
1722 into a file,
1723 or via
1724 .B getline
1725 from a file,
1726 .I gawk
1727 recognizes certain special filenames internally.  These filenames
1728 allow access to open file descriptors inherited from
1729 .IR gawk 's
1730 parent process (usually the shell).
1731 Other special filenames provide access to information about the running
1732 .B gawk
1733 process.
1734 The filenames are:
1735 .TP \w'\fB/dev/stdout\fR'u+1n
1736 .B /dev/pid
1737 Reading this file returns the process ID of the current process,
1738 in decimal, terminated with a newline.
1739 .TP
1740 .B /dev/ppid
1741 Reading this file returns the parent process ID of the current process,
1742 in decimal, terminated with a newline.
1743 .TP
1744 .B /dev/pgrpid
1745 Reading this file returns the process group ID of the current process,
1746 in decimal, terminated with a newline.
1747 .TP
1748 .B /dev/user
1749 Reading this file returns a single record terminated with a newline.
1750 The fields are separated with spaces.
1751 .B $1
1752 is the value of the
1753 .IR getuid (2)
1754 system call,
1755 .B $2
1756 is the value of the
1757 .IR geteuid (2)
1758 system call,
1759 .B $3
1760 is the value of the
1761 .IR getgid (2)
1762 system call, and
1763 .B $4
1764 is the value of the
1765 .IR getegid (2)
1766 system call.
1767 If there are any additional fields, they are the group IDs returned by
1768 .IR getgroups (2).
1769 Multiple groups may not be supported on all systems.
1770 .TP
1771 .B /dev/stdin
1772 The standard input.
1773 .TP
1774 .B /dev/stdout
1775 The standard output.
1776 .TP
1777 .B /dev/stderr
1778 The standard error output.
1779 .TP
1780 .BI /dev/fd/\^ n
1781 The file associated with the open file descriptor
1782 .IR n .
1783 .PP
1784 These are particularly useful for error messages. For example:
1785 .PP
1786 .RS
1787 .ft B
1788 print "You blew it!" > "/dev/stderr"
1789 .ft R
1790 .RE
1791 .PP
1792 whereas you would otherwise have to use
1793 .PP
1794 .RS
1795 .ft B
1796 print "You blew it!" | "cat 1>&2"
1797 .ft R
1798 .RE
1799 .PP
1800 These file names may also be used on the command line to name data files.
1801 .SS Numeric Functions
1802 .PP
1803 AWK has the following pre-defined arithmetic functions:
1804 .PP
1805 .TP \w'\fBsrand(\fR[\fIexpr\^\fR]\fB)\fR'u+1n
1806 .BI atan2( y , " x" )
1807 returns the arctangent of
1808 .I y/x
1809 in radians.
1810 .TP
1811 .BI cos( expr )
1812 returns the cosine of
1813 .IR expr ,
1814 which is in radians.
1815 .TP
1816 .BI exp( expr )
1817 the exponential function.
1818 .TP
1819 .BI int( expr )
1820 truncates to integer.
1821 .TP
1822 .BI log( expr )
1823 the natural logarithm function.
1824 .TP
1825 .B rand()
1826 returns a random number between 0 and 1.
1827 .TP
1828 .BI sin( expr )
1829 returns the sine of
1830 .IR expr ,
1831 which is in radians.
1832 .TP
1833 .BI sqrt( expr )
1834 the square root function.
1835 .TP
1836 \&\fBsrand(\fR[\fIexpr\^\fR]\fB)\fR
1837 uses
1838 .I expr
1839 as a new seed for the random number generator. If no
1840 .I expr
1841 is provided, the time of day will be used.
1842 The return value is the previous seed for the random
1843 number generator.
1844 .SS String Functions
1845 .PP
1846 .I Gawk
1847 has the following pre-defined string functions:
1848 .PP
1849 .TP "\w'\fBsprintf(\^\fIfmt\fB\^, \fIexpr-list\^\fB)\fR'u+1n"
1850 \fBgensub(\fIr\fB, \fIs\fB, \fIh \fR[\fB, \fIt\fR]\fB)\fR
1851 search the target string
1852 .I t
1853 for matches of the regular expression
1854 .IR r .
1855 If
1856 .I h
1857 is a string beginning with
1858 .B g
1859 or
1860 .BR G ,
1861 then replace all matches of
1862 .I r
1863 with
1864 .IR s .
1865 Otherwise,
1866 .I h
1867 is a number indicating which match of
1868 .I r
1869 to replace.
1870 If no
1871 .I t
1872 is supplied,
1873 .B $0
1874 is used instead.
1875 Within the replacement text
1876 .IR s ,
1877 the sequence
1878 .BI \e n\fR,
1879 where
1880 .I n
1881 is a digit from 1 to 9, may be used to indicate just the text that
1882 matched the
1883 .IR n 'th
1884 parenthesized subexpression. The sequence
1885 .B \e0
1886 represents the entire matched text, as does the character
1887 .BR & .
1888 Unlike
1889 .B sub()
1890 and
1891 .BR gsub() ,
1892 the modified string is returned as the result of the function,
1893 and the original target string is
1894 .I not
1895 changed.
1896 .TP "\w'\fBsprintf(\^\fIfmt\fB\^, \fIexpr-list\^\fB)\fR'u+1n"
1897 \fBgsub(\fIr\fB, \fIs \fR[\fB, \fIt\fR]\fB)\fR
1898 for each substring matching the regular expression
1899 .I r
1900 in the string
1901 .IR t ,
1902 substitute the string
1903 .IR s ,
1904 and return the number of substitutions.
1905 If
1906 .I t
1907 is not supplied, use
1908 .BR $0 .
1909 An
1910 .B &
1911 in the replacement text is replaced with the text that was actually matched.
1912 Use
1913 .B \e&
1914 to get a literal
1915 .BR & .
1916 See
1917 .I "AWK Language Programming"
1918 for a fuller discussion of the rules for
1919 .BR &'s
1920 and backslashes in the replacement text of
1921 .BR sub() ,
1922 .BR gsub() ,
1923 and
1924 .BR gensub() .
1925 .TP
1926 .BI index( s , " t" )
1927 returns the index of the string
1928 .I t
1929 in the string
1930 .IR s ,
1931 or 0 if
1932 .I t
1933 is not present.
1934 .TP
1935 \fBlength(\fR[\fIs\fR]\fB)
1936 returns the length of the string
1937 .IR s ,
1938 or the length of
1939 .B $0
1940 if
1941 .I s
1942 is not supplied.
1943 .TP
1944 .BI match( s , " r" )
1945 returns the position in
1946 .I s
1947 where the regular expression
1948 .I r
1949 occurs, or 0 if
1950 .I r
1951 is not present, and sets the values of
1952 .B RSTART
1953 and
1954 .BR RLENGTH .
1955 .TP
1956 \fBsplit(\fIs\fB, \fIa \fR[\fB, \fIr\fR]\fB)\fR
1957 splits the string
1958 .I s
1959 into the array
1960 .I a
1961 on the regular expression
1962 .IR r ,
1963 and returns the number of fields. If
1964 .I r
1965 is omitted,
1966 .B FS
1967 is used instead.
1968 The array
1969 .I a
1970 is cleared first.
1971 Splitting behaves identically to field splitting, described above.
1972 .TP
1973 .BI sprintf( fmt , " expr-list" )
1974 prints
1975 .I expr-list
1976 according to
1977 .IR fmt ,
1978 and returns the resulting string.
1979 .TP
1980 \fBsub(\fIr\fB, \fIs \fR[\fB, \fIt\fR]\fB)\fR
1981 just like
1982 .BR gsub() ,
1983 but only the first matching substring is replaced.
1984 .TP
1985 \fBsubstr(\fIs\fB, \fIi \fR[\fB, \fIn\fR]\fB)\fR
1986 returns the at most
1987 .IR n -character
1988 substring of
1989 .I s
1990 starting at
1991 .IR i .
1992 If
1993 .I n
1994 is omitted, the rest of
1995 .I s
1996 is used.
1997 .TP
1998 .BI tolower( str )
1999 returns a copy of the string
2000 .IR str ,
2001 with all the upper-case characters in
2002 .I str
2003 translated to their corresponding lower-case counterparts.
2004 Non-alphabetic characters are left unchanged.
2005 .TP
2006 .BI toupper( str )
2007 returns a copy of the string
2008 .IR str ,
2009 with all the lower-case characters in
2010 .I str
2011 translated to their corresponding upper-case counterparts.
2012 Non-alphabetic characters are left unchanged.
2013 .SS Time Functions
2014 .PP
2015 Since one of the primary uses of AWK programs is processing log files
2016 that contain time stamp information,
2017 .I gawk
2018 provides the following two functions for obtaining time stamps and
2019 formatting them.
2020 .PP
2021 .TP "\w'\fBsystime()\fR'u+1n"
2022 .B systime()
2023 returns the current time of day as the number of seconds since the Epoch
2024 (Midnight UTC, January 1, 1970 on \*(PX systems).
2025 .TP
2026 \fBstrftime(\fR[\fIformat \fR[\fB, \fItimestamp\fR]]\fB)\fR
2027 formats
2028 .I timestamp
2029 according to the specification in
2030 .IR format.
2031 The
2032 .I timestamp
2033 should be of the same form as returned by
2034 .BR systime() .
2035 If
2036 .I timestamp
2037 is missing, the current time of day is used.
2038 If
2039 .I format
2040 is missing, a default format equivalent to the output of
2041 .IR date (1)
2042 will be used.
2043 See the specification for the
2044 .B strftime()
2045 function in \*(AN C for the format conversions that are
2046 guaranteed to be available.
2047 A public-domain version of
2048 .IR strftime (3)
2049 and a man page for it come with
2050 .IR gawk ;
2051 if that version was used to build
2052 .IR gawk ,
2053 then all of the conversions described in that man page are available to
2054 .IR gawk.
2055 .SS String Constants
2056 .PP
2057 String constants in AWK are sequences of characters enclosed
2058 between double quotes (\fB"\fR). Within strings, certain
2059 .I "escape sequences"
2060 are recognized, as in C. These are:
2061 .PP
2062 .TP \w'\fB\e\^\fIddd\fR'u+1n
2063 .B \e\e
2064 A literal backslash.
2065 .TP
2066 .B \ea
2067 The ``alert'' character; usually the \s-1ASCII\s+1 \s-1BEL\s+1 character.
2068 .TP
2069 .B \eb
2070 backspace.
2071 .TP
2072 .B \ef
2073 form-feed.
2074 .TP
2075 .B \en
2076 newline.
2077 .TP
2078 .B \er
2079 carriage return.
2080 .TP
2081 .B \et
2082 horizontal tab.
2083 .TP
2084 .B \ev
2085 vertical tab.
2086 .TP
2087 .BI \ex "\^hex digits"
2088 The character represented by the string of hexadecimal digits following
2089 the
2090 .BR \ex .
2091 As in \*(AN C, all following hexadecimal digits are considered part of
2092 the escape sequence.
2093 (This feature should tell us something about language design by committee.)
2094 E.g., \fB"\ex1B"\fR is the \s-1ASCII\s+1 \s-1ESC\s+1 (escape) character.
2095 .TP
2096 .BI \e ddd
2097 The character represented by the 1-, 2-, or 3-digit sequence of octal
2098 digits. E.g. \fB"\e033"\fR is the \s-1ASCII\s+1 \s-1ESC\s+1 (escape) character.
2099 .TP
2100 .BI \e c
2101 The literal character
2102 .IR c\^ .
2103 .PP
2104 The escape sequences may also be used inside constant regular expressions
2105 (e.g.,
2106 .B "/[\ \et\ef\en\er\ev]/"
2107 matches whitespace characters).
2108 .PP
2109 In compatibility mode, the characters represented by octal and
2110 hexadecimal escape sequences are treated literally when used in
2111 regexp constants. Thus,
2112 .B /a\e52b/
2113 is equivalent to
2114 .BR /a\e*b/ .
2115 .SH FUNCTIONS
2116 Functions in AWK are defined as follows:
2117 .PP
2118 .RS
2119 \fBfunction \fIname\fB(\fIparameter list\fB) { \fIstatements \fB}\fR
2120 .RE
2121 .PP
2122 Functions are executed when they are called from within expressions
2123 in either patterns or actions.  Actual parameters supplied in the function
2124 call are used to instantiate the formal parameters declared in the function.
2125 Arrays are passed by reference, other variables are passed by value.
2126 .PP
2127 Since functions were not originally part of the AWK language, the provision
2128 for local variables is rather clumsy: They are declared as extra parameters
2129 in the parameter list. The convention is to separate local variables from
2130 real parameters by extra spaces in the parameter list. For example:
2131 .PP
2132 .RS
2133 .ft B
2134 .nf
2135 function  f(p, q,     a, b)     # a & b are local
2136 {
2137         \&.....
2138 }
2139
2140 /abc/   { ... ; f(1, 2) ; ... }
2141 .fi
2142 .ft R
2143 .RE
2144 .PP
2145 The left parenthesis in a function call is required
2146 to immediately follow the function name,
2147 without any intervening white space.
2148 This is to avoid a syntactic ambiguity with the concatenation operator.
2149 This restriction does not apply to the built-in functions listed above.
2150 .PP
2151 Functions may call each other and may be recursive.
2152 Function parameters used as local variables are initialized
2153 to the null string and the number zero upon function invocation.
2154 .PP
2155 Use
2156 .BI return " expr"
2157 to return a value from a function. The return value is undefined if no
2158 value is provided, or if the function returns by ``falling off'' the
2159 end.
2160 .PP
2161 If
2162 .B \-\^\-lint
2163 has been provided,
2164 .I gawk
2165 will warn about calls to undefined functions at parse time,
2166 instead of at run time.
2167 Calling an undefined function at run time is a fatal error.
2168 .PP
2169 The word
2170 .B func
2171 may be used in place of
2172 .BR function .
2173 .SH EXAMPLES
2174 .nf
2175 Print and sort the login names of all users:
2176
2177 .ft B
2178         BEGIN   { FS = ":" }
2179                 { print $1 | "sort" }
2180
2181 .ft R
2182 Count lines in a file:
2183
2184 .ft B
2185                 { nlines++ }
2186         END     { print nlines }
2187
2188 .ft R
2189 Precede each line by its number in the file:
2190
2191 .ft B
2192         { print FNR, $0 }
2193
2194 .ft R
2195 Concatenate and line number (a variation on a theme):
2196
2197 .ft B
2198         { print NR, $0 }
2199 .ft R
2200 .fi
2201 .SH SEE ALSO
2202 .IR egrep (1),
2203 .IR getpid (2),
2204 .IR getppid (2),
2205 .IR getpgrp (2),
2206 .IR getuid (2),
2207 .IR geteuid (2),
2208 .IR getgid (2),
2209 .IR getegid (2),
2210 .IR getgroups (2)
2211 .PP
2212 .IR "The AWK Programming Language" ,
2213 Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger,
2214 Addison-Wesley, 1988. ISBN 0-201-07981-X.
2215 .PP
2216 .IR "AWK Language Programming" ,
2217 Edition 1.0, published by the Free Software Foundation, 1995.
2218 .SH POSIX COMPATIBILITY
2219 A primary goal for
2220 .I gawk
2221 is compatibility with the \*(PX standard, as well as with the
2222 latest version of \*(UX
2223 .IR awk .
2224 To this end,
2225 .I gawk
2226 incorporates the following user visible
2227 features which are not described in the AWK book,
2228 but are part of the Bell Labs version of
2229 .IR awk ,
2230 and are in the \*(PX standard.
2231 .PP
2232 The
2233 .B \-v
2234 option for assigning variables before program execution starts is new.
2235 The book indicates that command line variable assignment happens when
2236 .I awk
2237 would otherwise open the argument as a file, which is after the
2238 .B BEGIN
2239 block is executed.  However, in earlier implementations, when such an
2240 assignment appeared before any file names, the assignment would happen
2241 .I before
2242 the
2243 .B BEGIN
2244 block was run.  Applications came to depend on this ``feature.''
2245 When
2246 .I awk
2247 was changed to match its documentation, this option was added to
2248 accommodate applications that depended upon the old behavior.
2249 (This feature was agreed upon by both the AT&T and GNU developers.)
2250 .PP
2251 The
2252 .B \-W
2253 option for implementation specific features is from the \*(PX standard.
2254 .PP
2255 When processing arguments,
2256 .I gawk
2257 uses the special option ``\fB\-\^\-\fP'' to signal the end of
2258 arguments.
2259 In compatibility mode, it will warn about, but otherwise ignore,
2260 undefined options.
2261 In normal operation, such arguments are passed on to the AWK program for
2262 it to process.
2263 .PP
2264 The AWK book does not define the return value of
2265 .BR srand() .
2266 The \*(PX standard
2267 has it return the seed it was using, to allow keeping track
2268 of random number sequences. Therefore
2269 .B srand()
2270 in
2271 .I gawk
2272 also returns its current seed.
2273 .PP
2274 Other new features are:
2275 The use of multiple
2276 .B \-f
2277 options (from MKS
2278 .IR awk );
2279 the
2280 .B ENVIRON
2281 array; the
2282 .BR \ea ,
2283 and
2284 .BR \ev
2285 escape sequences (done originally in
2286 .I gawk
2287 and fed back into AT&T's); the
2288 .B tolower()
2289 and
2290 .B toupper()
2291 built-in functions (from AT&T); and the \*(AN C conversion specifications in
2292 .B printf
2293 (done first in AT&T's version).
2294 .SH GNU EXTENSIONS
2295 .I Gawk
2296 has a number of extensions to \*(PX
2297 .IR awk .
2298 They are described in this section.  All the extensions described here
2299 can be disabled by
2300 invoking
2301 .I gawk
2302 with the
2303 .B \-\^\-traditional
2304 option.
2305 .PP
2306 The following features of
2307 .I gawk
2308 are not available in
2309 \*(PX
2310 .IR awk .
2311 .RS
2312 .TP \w'\(bu'u+1n
2313 \(bu
2314 The
2315 .B \ex
2316 escape sequence.
2317 (Disabled with
2318 .BR \-\^\-posix .)
2319 .TP \w'\(bu'u+1n
2320 \(bu
2321 The
2322 .B fflush()
2323 function.
2324 (Disabled with
2325 .BR \-\^\-posix .)
2326 .TP
2327 \(bu
2328 The
2329 .BR systime(),
2330 .BR strftime(),
2331 and
2332 .B gensub()
2333 functions.
2334 .TP
2335 \(bu
2336 The special file names available for I/O redirection are not recognized.
2337 .TP
2338 \(bu
2339 The
2340 .BR ARGIND ,
2341 .BR ERRNO ,
2342 and
2343 .B RT
2344 variables are not special.
2345 .TP
2346 \(bu
2347 The
2348 .B IGNORECASE
2349 variable and its side-effects are not available.
2350 .TP
2351 \(bu
2352 The
2353 .B FIELDWIDTHS
2354 variable and fixed-width field splitting.
2355 .TP
2356 \(bu
2357 The use of
2358 .B RS
2359 as a regular expression.
2360 .TP
2361 \(bu
2362 The ability to split out individual characters using the null string
2363 as the value of
2364 .BR FS ,
2365 and as the third argument to
2366 .BR split() .
2367 .TP
2368 \(bu
2369 No path search is performed for files named via the
2370 .B \-f
2371 option.  Therefore the
2372 .B AWKPATH
2373 environment variable is not special.
2374 .TP
2375 \(bu
2376 The use of
2377 .B "nextfile"
2378 to abandon processing of the current input file.
2379 .TP
2380 \(bu
2381 The use of
2382 .BI delete " array"
2383 to delete the entire contents of an array.
2384 .RE
2385 .PP
2386 The AWK book does not define the return value of the
2387 .B close()
2388 function.
2389 .IR Gawk\^ 's
2390 .B close()
2391 returns the value from
2392 .IR fclose (3),
2393 or
2394 .IR pclose (3),
2395 when closing a file or pipe, respectively.
2396 .PP
2397 When
2398 .I gawk
2399 is invoked with the
2400 .B \-\^\-traditional
2401 option,
2402 if the
2403 .I fs
2404 argument to the
2405 .B \-F
2406 option is ``t'', then
2407 .B FS
2408 will be set to the tab character.
2409 Note that typing
2410 .B "gawk \-F\et \&..."
2411 simply causes the shell to quote the ``t,'', and does not pass
2412 ``\et'' to the
2413 .B \-F
2414 option.
2415 Since this is a rather ugly special case, it is not the default behavior.
2416 This behavior also does not occur if
2417 .B \-\^\-posix
2418 has been specified.
2419 To really get a tab character as the field separator, it is best to use
2420 quotes:
2421 .BR "gawk \-F'\et' \&..." .
2422 .ig
2423 .PP
2424 If
2425 .I gawk
2426 was compiled for debugging, it will
2427 accept the following additional options:
2428 .TP
2429 .PD 0
2430 .B \-Wparsedebug
2431 .TP
2432 .PD
2433 .B \-\^\-parsedebug
2434 Turn on
2435 .IR yacc (1)
2436 or
2437 .IR bison (1)
2438 debugging output during program parsing.
2439 This option should only be of interest to the
2440 .I gawk
2441 maintainers, and may not even be compiled into
2442 .IR gawk .
2443 ..
2444 .SH HISTORICAL FEATURES
2445 There are two features of historical AWK implementations that
2446 .I gawk
2447 supports.
2448 First, it is possible to call the
2449 .B length()
2450 built-in function not only with no argument, but even without parentheses!
2451 Thus,
2452 .RS
2453 .PP
2454 .ft B
2455 a = length      # Holy Algol 60, Batman!
2456 .ft R
2457 .RE
2458 .PP
2459 is the same as either of
2460 .RS
2461 .PP
2462 .ft B
2463 a = length()
2464 .br
2465 a = length($0)
2466 .ft R
2467 .RE
2468 .PP
2469 This feature is marked as ``deprecated'' in the \*(PX standard, and
2470 .I gawk
2471 will issue a warning about its use if
2472 .B \-\^\-lint
2473 is specified on the command line.
2474 .PP
2475 The other feature is the use of either the
2476 .B continue
2477 or the
2478 .B break
2479 statements outside the body of a
2480 .BR while ,
2481 .BR for ,
2482 or
2483 .B do
2484 loop.  Traditional AWK implementations have treated such usage as
2485 equivalent to the
2486 .B next
2487 statement.
2488 .I Gawk
2489 will support this usage if
2490 .B \-\^\-traditional
2491 has been specified.
2492 .SH ENVIRONMENT
2493 If
2494 .B POSIXLY_CORRECT
2495 exists in the environment, then
2496 .I gawk
2497 behaves exactly as if
2498 .B \-\^\-posix
2499 had been specified on the command line.
2500 If
2501 .B \-\^\-lint
2502 has been specified,
2503 .I gawk
2504 will issue a warning message to this effect.
2505 .PP
2506 The
2507 .B AWKPATH
2508 environment variable can be used to provide a list of directories that
2509 .I gawk
2510 will search when looking for files named via the
2511 .B \-f
2512 and
2513 .B \-\^\-file
2514 options.
2515 .SH BUGS
2516 The
2517 .B \-F
2518 option is not necessary given the command line variable assignment feature;
2519 it remains only for backwards compatibility.
2520 .PP
2521 If your system actually has support for
2522 .B /dev/fd
2523 and the associated
2524 .BR /dev/stdin ,
2525 .BR /dev/stdout ,
2526 and
2527 .B /dev/stderr
2528 files, you may get different output from
2529 .I gawk
2530 than you would get on a system without those files.  When
2531 .I gawk
2532 interprets these files internally, it synchronizes output to the standard
2533 output with output to
2534 .BR /dev/stdout ,
2535 while on a system with those files, the output is actually to different
2536 open files.
2537 Caveat Emptor.
2538 .PP
2539 Syntactically invalid single character programs tend to overflow
2540 the parse stack, generating a rather unhelpful message.  Such programs
2541 are surprisingly difficult to diagnose in the completely general case,
2542 and the effort to do so really is not worth it.
2543 .SH VERSION INFORMATION
2544 This man page documents
2545 .IR gawk ,
2546 version 3.0.4.
2547 .SH AUTHORS
2548 The original version of \*(UX
2549 .I awk
2550 was designed and implemented by Alfred Aho,
2551 Peter Weinberger, and Brian Kernighan of AT&T Bell Labs. Brian Kernighan
2552 continues to maintain and enhance it.
2553 .PP
2554 Paul Rubin and Jay Fenlason,
2555 of the Free Software Foundation, wrote
2556 .IR gawk ,
2557 to be compatible with the original version of
2558 .I awk
2559 distributed in Seventh Edition \*(UX.
2560 John Woods contributed a number of bug fixes.
2561 David Trueman, with contributions
2562 from Arnold Robbins, made
2563 .I gawk
2564 compatible with the new version of \*(UX
2565 .IR awk .
2566 Arnold Robbins is the current maintainer.
2567 .PP
2568 The initial DOS port was done by Conrad Kwok and Scott Garfinkle.
2569 Scott Deifik is the current DOS maintainer.  Pat Rankin did the
2570 port to VMS, and Michal Jaegermann did the port to the Atari ST.
2571 The port to OS/2 was done by Kai Uwe Rommel, with contributions and
2572 help from Darrel Hankerson.  Fred Fish supplied support for the Amiga.
2573 .SH BUG REPORTS
2574 If you find a bug in
2575 .IR gawk ,
2576 please send electronic mail to
2577 .BR bug-gnu-utils@gnu.org ,
2578 .I with
2579 a carbon copy to
2580 .BR arnold@gnu.org .
2581 Please include your operating system and its revision, the version of
2582 .IR gawk ,
2583 what C compiler you used to compile it, and a test program
2584 and data that are as small as possible for reproducing the problem.
2585 .PP
2586 Before sending a bug report, please do two things. First, verify that
2587 you have the latest version of
2588 .IR gawk .
2589 Many bugs (usually subtle ones) are fixed at each release, and if
2590 yours is out of date, the problem may already have been solved.
2591 Second, please read this man page and the reference manual carefully to
2592 be sure that what you think is a bug really is, instead of just a quirk
2593 in the language.
2594 .PP
2595 Whatever you do, do
2596 .B NOT
2597 post a bug report in
2598 .BR comp.lang.awk .
2599 While the
2600 .I gawk
2601 developers occasionally read this newsgroup, posting bug reports there
2602 is an unreliable way to report bugs. Instead, please use the electronic mail
2603 addresses given above.
2604 .SH ACKNOWLEDGEMENTS
2605 Brian Kernighan of Bell Labs
2606 provided valuable assistance during testing and debugging.
2607 We thank him.
2608 .SH COPYING PERMISSIONS
2609 Copyright \(co) 1996,97,98,99 Free Software Foundation, Inc.
2610 .PP
2611 Permission is granted to make and distribute verbatim copies of
2612 this manual page provided the copyright notice and this permission
2613 notice are preserved on all copies.
2614 .ig
2615 Permission is granted to process this file through troff and print the
2616 results, provided the printed document carries copying permission
2617 notice identical to this one except for the removal of this paragraph
2618 (this paragraph not being relevant to the printed manual page).
2619 ..
2620 .PP
2621 Permission is granted to copy and distribute modified versions of this
2622 manual page under the conditions for verbatim copying, provided that
2623 the entire resulting derived work is distributed under the terms of a
2624 permission notice identical to this one.
2625 .PP
2626 Permission is granted to copy and distribute translations of this
2627 manual page into another language, under the above conditions for
2628 modified versions, except that this permission notice may be stated in
2629 a translation approved by the Foundation.