48
\*(FRAWK Program Execution 4
48
\*(FRAction Statements 7
50
Awk Program Execution 4
51
Bit Manipulation Functions (\*(GK) 16
53
Closing Redirections 12
52
54
Command Line Arguments (standard) 2
53
55
Command Line Arguments (\*(GK) 3
54
56
Command Line Arguments (\*(MK) 4
55
Conversions And Comparisons 10
56
Copying Permissions 16
57
Conversions And Comparisons 9
58
Copying Permissions 18
58
Environment Variables 16
60
Dynamic Extensions (\*(GK) 18
61
Environment Variables (\*(GK) 18
63
Historical Features (\*(GK) 16
65
FTP/HTTP Information 18
66
Historical Features (\*(GK) 18
68
Internationalization (\*(GK) 16
65
69
Lines And Statements 5
70
Localization (\*(GK) 17
72
74
POSIX Character Classes (\*(GK) 6
75
77
Regular Expressions 5
78
Time Functions (\*(GK) 15
79
User-defined Functions 15
80
Time Functions (\*(GK) 16
81
User-defined Functions 17
82
84
.EB "\s+2\f(HBCONTENTS\*(FR\s0"
86
\*(CD\*(FRThis reference card was written by Arnold Robbins.
87
Brian Kernighan and Michael Brennan reviewed it; we thank them
88
\*(CD\*(FRArnold Robbins wrote this reference card.
90
Brian Kernighan and Michael Brennan who reviewed it.
92
94
.so SRCDIR/ad.block
93
95
.\" a subtlety here; this line changes color. We rely on it
94
96
.\" also to provide a blank line.
98
\*(FR\(co Copyright 1996-2000, Free Software Foundation
100
\*(FR\(co Copyright 1996-2001, Free Software Foundation
99
101
59 Temple Place \(em Suite 330
100
102
Boston, MA 02111-1307 USA
202
208
.EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (standard)\*(FR\s0"
213
\*(CDIf you find a bug in this reference card, please report it via electronic
214
mail to \*(FCbug-gawk@gnu.org\*(FR.\*(CX
215
.EB "\s+2\f(HBBUG REPORTS\*(FR\s0"
221
.\" --- Command Line Arguments (gawk)
208
\*(CDThe following options are specific to \*(GK. The \*(FC\-W\*(FR
209
forms are for full POSIX compliance.
224
\*(CDThe following options are specific to \*(GK.
225
You may also use ``\*(FC\-W \*(FIoption\*(FR''
226
for full POSIX compliance.
227
Long options may abbreviated as long as the abbreviation
212
231
.\" This option is left undocumented, on purpose.
213
\*(FC\-\^\-nostalgia\*(FR
214
\*(FC\-W nostalgia\*(FR%T{
232
\*(FC\-\^\-nostalgia\*(FR%T{
215
233
provide a moment of nostalgia for
216
234
long time \*(AK users.
240
\*(FC\-\^\-assign \*(FIvar\*(FC\^=\^\*(FIval\*(FR%just like \*(FC\-v\fP.
241
\*(FC\-\^\-field-separator \*(FIfs\*(FR%just like \*(FC\-F\fP.
242
\*(FC\-\^\-file \*(FIprog-file%\*(FRjust like \*(FC\-f\fP.
223
\*(FC\-\^\-field-separator \*(FIfs\*(FR
224
%just like \*(FC\-F\fP
225
\*(FC\-\^\-assign \*(FIvar\*(FC\^=\^\*(FIval\*(FR%just like \*(FC\-v\fP
226
\*(FC\-\^\-file \*(FIprog-file%\*(FRjust like \*(FC\-f\fP
227
\*(FC\-\^\-traditional\*(FR
228
\*(FC\-\^\-compat\*(FR
230
\*(FC\-W traditional\*(FR%T{
231
turn off \*(GK-specific extensions
232
(\*(FC\-\^\-traditional\*(FR preferred).
248
\*(FC\-\^\-compat\*(FR, \*(FC\-\^\-traditional\*(FR
250
disable \*(GK-specific extensions
251
(the use of \*(FC\-\^\-traditional\*(FR is preferred).
234
\*(FC\-\^\-copyleft\*(FR
235
\*(FC\-\^\-copyright\*(FR
236
\*(FC\-W copyleft\*(FR
237
\*(FC\-W copyright\*(FR%T{
256
\*(FC\-\^\-copyleft\*(FR, \*(FC\-\^\-copyright\*(FR
238
258
print the short version of the GNU
239
259
copyright information on \*(FCstdout\*(FR.
242
\*(FC\-\^\-usage\*(FR
244
\*(FC\-W usage\*(FR%T{
264
\*(FC\-\^\-dump-variables\*(FR[\*(FC=\*(FIfile\*(FR]
266
Print a sorted list of global variables,
267
their types and final values to
270
is provided, \*(FCgawk\*(FR
271
uses \*(FCawkvars.out\*(FR.
273
\*(FC\-\^\-gen\-po\*(FR%T{
274
process the program and print a GNU \*(FCgettext\*(FR
275
format \*(FC\&.po\*(FR format file on standard output,
276
containing the text of all strings that were marked
282
\*(FC\-\^\-help\*(FR, \*(FC\-\^\-usage\*(FR
245
284
print a short summary of the available
246
285
options on \*(FCstdout\*(FR, then exit zero.
249
\*(FC\-W lint\*(FR%T{
290
\*(FC\-\^\-lint\*(FR[\*(FC=fatal\*(FR]
250
292
warn about constructs that are dubious
251
293
or non-portable to other \*(AKs.
294
With an optional argument of \*(FCfatal\*(FR,
295
lint warnings become fatal errors.
253
\*(FC\-\^\-lint\-old\*(FR
254
\*(FC\-W lint\-old\*(FR%T{
299
\*(FC\-\^\-lint\-old\*(FR%T{
255
300
warn about constructs that are not
256
301
portable to the original version of
259
\*(FC\-\^\-posix\*(FR
260
\*(FC\-W posix\*(FR%T{
307
\*(FC\-\^\-non\-decimal\-data\*(FR
309
recognize octal and hexadecimal values in input data.
310
\*(FIUse this option with great caution!\*(FR
314
\*(FC\-\^\-posix\*(FR%T{
261
315
disable common and GNU extensions.
262
316
Enable \*(FIinterval expressions\*(FR in regular
263
317
expression matching (see \fHRegular
264
318
Expressions\fP below).
323
\*(FC\-\^\-profile\*(FR[\*(FC=\*(FIprof_file\*(FR]
325
send profiling data to \*(FIprof_file\*(FR
326
(default: \*(FCawkprof.out\*(FR).
328
the profile is just a ``pretty printed'' version of the program.
329
With \*(FIpgawk\*(FR,
330
the profile contains execution counts in the left margin
331
of each statement in the program.
266
336
\*(FC\-\^\-re\-interval\*(FR
267
\*(FC\-W re\-interval\*(FR%T{
268
338
enable \*(FIinterval expressions\*(FR in regular
269
339
expression matching (see \fHRegular
270
340
Expressions\fP below). Useful if
271
341
\*(FC\-\^\-posix\*(FR is not specified.
273
346
\*(FC\-\^\-source '\*(FItext\*(FC'\*(FR
274
\*(FC\-W source '\*(FItext\*(FC'\*(FR%use \*(FItext\*(FR as AWK program source code.
275
\*(FC\-\^\-version\*(FR
276
\*(FC\-W version\*(FR%T{
347
%use \*(FItext\*(FR as AWK program source code.
348
\*(FC\-\^\-version\*(FR%T{
277
349
print version information on \*(FCstdout\fP
283
355
In compatibility mode,
284
any other options are flagged as illegal, but are otherwise ignored.
356
any other options are flagged as invalid, but are otherwise ignored.
285
357
In normal operation, as long as program text has been supplied, unknown
286
358
options are passed on to the AWK program in
288
360
for processing. This is most useful for running AWK
289
programs via the \*(FC#!\*(FR executable interpreter mechanism.\*(CB
361
programs via the \*(FC#!\*(FR executable interpreter mechanism.
363
\*(FIpgawk\fP accepts two signals.
364
\*(FCSIGUSR1\fP causes it to dump a profile and function call stack to the
365
profile file. It then continues to run.
367
causes it to dump the profile and function call stack and then exit.\*(CB
290
368
.EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (\*(GK\f(HB)\*(FR\s0"
374
.\" --- Command Line Arguments (mawk)
296
377
\*(CDThe following options are specific to \*(MK.
548
632
\*(CLand/or newlines\*(CD.
549
633
Leading and trailing whitespace are ignored.
550
634
\*(CBThe value of \*(FCIGNORECASE\fP
551
will also affect how fields are split when
635
also affects how fields are split when
552
636
\*(FCFS\fP is a regular expression.\*(CD
554
638
\*(CBIf the \*(FCFIELDWIDTHS\fP
555
variable is set to a space separated list of numbers, each field is
639
variable is set to a space-separated list of numbers, each field is
556
640
expected to have a fixed width, and \*(GK
557
will split up the record using the specified widths.
641
splits up the record using the specified widths.
558
642
The value of \*(FCFS\fP is ignored.
559
643
Assigning a new value to \*(FCFS\fP
560
644
overrides the use of \*(FCFIELDWIDTHS\*(FR,
571
655
References to non-existent fields (i.e., fields after \*(FC$NF\*(FR)
572
656
produce the null-string. However, assigning to a non-existent field
573
(e.g., \*(FC$(NF+2) = 5\*(FR) will increase the value of
574
\*(FCNF\*(FR, create any intervening fields with the null string as their value,
575
and cause the value of \*(FC$0\fP
657
(e.g., \*(FC$(NF+2) = 5\*(FR) increases the value of
658
\*(FCNF\*(FR, creates any intervening fields with the null string as their value,
659
and causes the value of \*(FC$0\fP
576
660
to be recomputed with the fields being separated by the
577
661
value of \*(FCOFS\*(FR.
578
662
References to negative numbered fields cause a fatal error.
579
663
Decreasing the value of \*(FCNF\fP causes the trailing fields to be lost
580
664
\*(CR(not \*(NK).\*(CX
581
.EB \s+2\f(HBFIELDS\*(FR\s0
665
.EB "\s+2\f(HBFIELDS\*(FR\s0"
615
699
.\" --- Action Statements
618
\*(CD\*(FCif (\*(FIcondition\*(FC) \*(FIstatement\*(FR [ \*(FCelse\*(FI statement \*(FR]
619
\*(FCwhile (\*(FIcondition\*(FC) \*(FIstatement \*(FR
620
\*(FCdo \*(FIstatement \*(FCwhile (\*(FIcondition\*(FC)\*(FR
621
\*(FCfor (\*(FIexpr1\*(FC; \*(FIexpr2\*(FC; \*(FIexpr3\*(FC) \*(FIstatement\*(FR
622
\*(FCfor (\*(FIvar \*(FCin\*(FI array\*(FC) \*(FIstatement\*(FR
624
\*(CB\*(FCabort\*(FR [ \*(FIexpression\*(FR ]\*(CD
706
break out of the nearest enclosing \*(FCdo\*(FR, \*(FCfor\*(FR,
707
or \*(FCwhile\*(FR loop.
627
709
\*(FCcontinue\*(FR
711
skip the rest of the loop body.
712
Evaluate the \*(FIcondition\*(FR
713
part of the nearest enclosing \*(FCdo\*(FR or \*(FCwhile\*(FR loop,
714
or go to the \*(FIincr\*(FR part of a \*(FCfor\*(FR loop.
628
716
\*(FCdelete \*(FIarray\^\*(FC[\^\*(FIindex\^\*(FC]\*(FR
629
\*(CL\*(FCdelete \*(FIarray\^\*(FR\*(CD
718
delete element \*(FIindex\*(FR from array \*(FIarray\*(FR.
720
\*(CL\*(FCdelete \*(FIarray\^\*(FR
722
delete all elements from array \*(FIarray\*(FR.\*(CD
724
\*(FCdo \*(FIstatement \*(FCwhile (\*(FIcondition\*(FC)\*(FR
726
execute \*(FIstatement\*(FR while \*(FIcondition\*(FR is true.
727
The \*(FIstatement\*(FR is always executed at least once.
630
729
\*(FCexit\*(FR [ \*(FIexpression\*(FR ]
632
\*(CL\*(FCnextfile\*(FR \*(CR(not \*(MK)\*(CD
633
\*(FC{ \*(FIstatements \*(FC}\*(CX
731
terminate input record processing.
732
Execute the \*(FCEND\*(FR rule(s) if present.
733
If present, \*(FIexpression\*(FR becomes \*(AK's return value.
735
\*(FCfor (\*(FIinit\*(FC; \*(FIcond\*(FC; \*(FIincr\*(FC) \*(FIstatement\*(FR
737
execute \*(FIinit\*(FR.
738
Evaluate \*(FIcond\*(FR.
739
If it is true, execute \*(FIstatement\*(FR.
740
Execute \*(FIincr\*(FR before going back to the top to
741
re-evaluate \*(FIcond\*(FR.
742
Any of the three may be omitted.
743
A missing \*(FIcond\*(FR is considered to be true.
745
\*(FCfor (\*(FIvar \*(FCin\*(FI array\*(FC) \*(FIstatement\*(FR
747
execute \*(FIstatement\*(FR once for each subscript in \*(FIarray\*(FR,
748
with \*(FIvar\*(FR set to a different subscript each time through
751
\*(CD\*(FCif (\*(FIcondition\*(FC) \*(FIstatement1\*(FR [ \*(FCelse\*(FI statement2\*(FR ]
753
if \*(FIcondition\*(FR is true, execute \*(FIstatement1\*(FR,
754
otherwise execute \*(FIstatement2\*(FR. Each \*(FCelse\*(FR
755
matches the closest \*(FCif\*(FR.
757
\*(FCnext\*(FR see \fHInput Control.\fP
759
\*(CL\*(FCnextfile\*(FR \*(CR(not \*(MK) \*(CLsee \fHInput Control.\fP\*(CD
761
\*(FCwhile (\*(FIcondition\*(FC) \*(FIstatement \*(FR
763
while \*(FIcondition\*(FR is true, execute \*(FIstatement\*(FR.
765
\*(FC{ \*(FIstatements \*(FC}\*(FR
767
a list of statements enclosed in braces can be used anywhere
768
that a single statement would otherwise be used.\*(CX
634
770
.EB "\s+2\f(HBACTION STATEMENTS\*(FR\s0"
638
775
.\" --- Escape Sequences
683
810
contents of \*(FCARGV\fP can control the files used
813
\*(CL\*(FCBINMODE\fP T{
814
controls ``binary'' mode for all file I/O. Values of 1, 2, or 3,
815
indicate input, output, or all files, respectively, should use binary
816
I/O. \*(CR(Not \*(NK.) \*(CLApplies only to non-POSIX systems.
817
\*(CBFor \*(GK, string values of \*(FC"r"\fP, or \*(FC"w"\fP specify
818
that input files, or output files, respectively, should use binary I/O.
819
String values of \*(FC"rw"\fP or \*(FC"wr"\fP specify that all files
820
should use binary I/O. Any other string value is treated as \*(FC"rw"\fP,
821
but generates a warning message.\*(CD
686
823
\*(FCCONVFMT\fP T{
687
824
conversion format for numbers, default value
688
825
is \*(FC"%.6g"\*(FR.
690
827
\*(FCENVIRON\fP T{
691
array containing the the current environment.
828
array containing the current environment.
692
829
The array is indexed by the environment
693
830
variables, each element being the value of
696
833
\*(CB\*(FCERRNO\fP T{
697
contains a string describing the error when a
698
redirection or read for \*(FCgetline\*(FR fails, or if
834
string describing the error if a
699
838
\*(FCclose()\*(FR fails.
701
840
\*(FCFIELDWIDTHS\fP T{
732
880
output format for numbers, \*(FC"%.6g"\*(FR, by default.
733
\*(CROld versions of \*(AK also used this for number
734
to string conversion instead of \*(FCCONVFMT\fP.\*(CD
881
\*(CROld versions of \*(AK used this for number
882
to string conversion.\*(CX
885
.EB "\s+2\f(HBVARIABLES\*(FR\s0"
888
.\" --- Variables (continued)
737
895
output field separator, a space by default.
740
898
output record separator, a newline by default.
900
\*(CB\*(FCPROCINFO\fP T{
901
elements of this array provide access to info
902
about the running AWK program. See
903
\*(AM for details.\*(CD
906
length of the string matched by \*(FCmatch()\*(FR;
743
910
input record separator, a newline by default
744
911
(see \fHRecords\fP above).
914
index of the first character matched by
915
\*(FCmatch()\*(FR; 0 if no match.
746
917
\*(CB\*(FCRT\fP T{
747
918
record terminator. \*(GK sets \*(FCRT\fP to the input
748
919
text that matched the character or regular
749
920
expression specified by \*(FCRS\*(FR.\*(CD
752
index of the first character matched by
753
\*(FCmatch()\*(FR; 0 if no match.
756
length of the string matched by \*(FCmatch()\*(FR;
759
922
\*(FCSUBSEP\fP T{
760
923
character(s) used to separate multiple subscripts
761
in array elements, by default \*(FC"\e034"\*(FR. (see
762
\fHArrays\fP below).\*(CX
924
in array elements, by default \*(FC"\e034"\*(FR. (See
927
\*(CB\*(FCTEXTDOMAIN\fP T{
928
the application's text domain for internationalization;
929
used to find the localized
930
translations for the program's strings.\*(CX
765
.EB \s+2\f(HBVARIABLES\*(FR\s0
933
.EB "\s+2\f(HBVARIABLES (continued)\*(FR\s0"
935
.\" --- Conversions and Comparisons
938
\*(CDVariables and fields may be (floating point) numbers, strings or both.
939
Context determines how the value of a variable is interpreted. If used in
940
a numeric expression, it will be treated as a number, if used as a string
941
it will be treated as a string.
943
To force a variable to be treated as a number, add 0 to it; to force it
944
to be treated as a string, concatenate it with the null string.
946
When a string must be converted to a number, the conversion is accomplished
947
using \*(FIstrtod\*(FR(3).
948
A number is converted to a string by using the value of \*(FCCONVFMT\fP
949
as a format string for \*(FIsprintf\*(FR(3),
950
with the numeric value of the variable as the argument.
951
However, even though all numbers in AWK are floating-point,
952
integral values are \*(FIalways\fP converted as integers.
954
Comparisons are performed as follows:
955
If two variables are numeric, they are compared numerically.
956
If one value is numeric and the other has a string value that is a
957
``numeric string,'' then comparisons are also done numerically.
958
Otherwise, the numeric value is converted to a string, and a string
959
comparison is performed.
960
Two strings are compared, of course, as strings.
962
Note that string constants, such as \*(FC"57"\fP, are \*(FInot\fP
963
numeric strings, they are string constants. The idea of ``numeric string''
964
only applies to fields, \*(FCgetline\fP input,
965
\*(FCFILENAME\*(FR, \*(FCARGV\fP elements, \*(FCENVIRON\fP
966
elements and the elements of an array created by
967
\*(FCsplit()\fP that are numeric strings.
968
The basic idea is that \*(FIuser input\*(FR,
969
and only user input, that looks numeric,
970
should be treated that way.
971
\*(CRNote that the POSIX standard applies the concept of
972
``numeric string'' everywhere, even to string constants.
974
clearly incorrect, and none of the three free \*(AK\*(FRs do this.\*(CD
975
(Fortunately, this is fixed in the next version of the standard.)
977
Uninitialized variables have the numeric value 0 and the string value
979
(the null, or empty, string).\*(CX
980
.EB "\s+2\f(HBCONVERSIONS AND COMPARISONS\*(FR\s0"
987
.EB "\s+2\f(HBNOTES\*(FR\s0"
772
\*(CDAn arrays subscript is an expression between square brackets
994
\*(CDAn array subscript is an expression between square brackets
773
995
(\*(FC[ \*(FRand \*(FC]\*(FR).
774
996
If the expression is a list
775
\*(FC(\*(FIexpr\*(FC, \*(FIexpr \*(FC...)\*(FR,
997
(\*(FIexpr\*(FC, \*(FIexpr \*(FR...),
776
998
then the subscript is a string consisting of the
777
999
concatenation of the (string) value of each expression,
778
1000
separated by the value of the \*(FCSUBSEP\fP variable.
864
1086
\*(FC=\0+=\0\-=\0*=\0/=\0%=\0^=\0\*(CL**=\*(CD\fP
865
1087
assignment operators\*(CX
867
.EB \s+2\f(HBEXPRESSIONS\*(FR\s0
872
.\" --- Conversions and Comparisons
875
\*(CDVariables and fields may be (floating point) numbers, strings or both.
876
Context determines how the value of a variable is interpreted. If used in
877
a numeric expression, it will be treated as a number, if used as a string
878
it will be treated as a string.
880
To force a variable to be treated as a number, add 0 to it; to force it
881
to be treated as a string, concatenate it with the null string.
883
When a string must be converted to a number, the conversion is accomplished
884
using \*(FIatof\*(FR(3).
885
A number is converted to a string by using the value of \*(FCCONVFMT\fP
886
as a format string for \*(FIsprintf\*(FR(3),
887
with the numeric value of the variable as the argument.
888
However, even though all numbers in AWK are floating-point,
889
integral values are \*(FIalways\fP converted as integers.
891
Comparisons are performed as follows:
892
If two variables are numeric, they are compared numerically.
893
If one value is numeric and the other has a string value that is a
894
``numeric string,'' then comparisons are also done numerically.
895
Otherwise, the numeric value is converted to a string, and a string
896
comparison is performed.
897
Two strings are compared, of course, as strings.
898
\*(CRAccording to the POSIX standard, even if two strings are
899
numeric strings, a numeric comparison is performed. However, this is
900
clearly incorrect, and none of the three free \*(AK\*(FRs do this.\*(CD
902
Note that string constants, such as \*(FC"57"\fP, are \*(FInot\fP
903
numeric strings, they are string constants. The idea of ``numeric string''
904
only applies to fields, \*(FCgetline\fP input,
905
\*(FCFILENAME\*(FR, \*(FCARGV\fP elements, \*(FCENVIRON\fP
906
elements and the elements of an array created by
907
\*(FCsplit()\fP that are numeric strings.
908
The basic idea is that \*(FIuser input\*(FR,
909
and only user input, that looks numeric,
910
should be treated that way.
912
Uninitialized variables have the numeric value 0 and the string value
914
(the null, or empty, string).\*(CX
915
.EB "\s+2\f(HBCONVERSIONS AND COMPARISONS\*(FR\s0"
934
.EB "\s+2\f(HBLOCALIZATION\*(FR\s0"
940
\*(CD\fHISBN: 0-916151-97-2\*(FR
1089
.EB "\s+2\f(HBEXPRESSIONS\*(FR\s0"
947
1093
.\" --- Input Control
986
1136
pattern in the AWK program. Upon end
987
1137
of input data, execute any \*(FCEND\fP rule(s).
988
1138
\*(CREarlier versions of \*(GK used
989
\*(FCnext file\*(FR, as two words. This
990
generates a warning message and will
991
eventually be removed. \*(CR\*(MK does not
992
currently support \*(FCnextfile\*(FR.\*(CD
1139
\*(FCnext file\*(FR, as two words.
1140
This usage is no longer supported.
1141
\*(CR\*(MK does not currently support \*(FCnextfile\*(FR.\*(CD
996
\*(FCgetline\*(FR returns 0 on end of file, and \-1 on an
1145
\*(FCgetline\*(FR returns 0 on end of file and \-1 on an error.
1146
\*(CBUpon an error, \*(FCERRNO\*(FR contains a string describing
998
1148
.EB "\s+2\f(HBINPUT CONTROL\*(FR\s0"
1000
1150
.\" --- Output Control
1005
\*(CD\*(FCclose(\*(FIfile\*(FC)\*(FR
1007
close output file or pipe.
1009
1155
\*(CL\*(FCfflush(\*(FR[\*(FIfile\^\*(FR]\*(FC)\*(FR
1011
1157
flush any buffers associated
1012
1158
with the open output file or pipe \*(FIfile\*(FR.\*(CD
1013
\*(CBIf \*(FIfile\fP is missing, then standard output is flushed.
1014
If \*(FIfile\fP is the null string, then all open output files and pipes
1015
are flushed \*(CR(not \*(NK)\*(CD.
1159
\*(CBIf no \*(FIfile\fP, then flush standard output.
1160
If \*(FIfile\fP is null, then flush all open output files and pipes
1161
\*(CR(not \*(NK)\*(CD.
1019
print the current record. The output record is terminated
1020
with the value of \*(FCORS\fP.
1165
print the current record. Terminate output record
1022
1168
\*(FCprint \*(FIexpr-list\*(FR
1024
1170
print expressions. Each expression is separated
1025
by the value of \*(FCOFS\fP. The output record is
1026
terminated with the value of \*(FCORS\fP.
1171
by the value of \*(FCOFS\fP. Terminate the output record
1028
1174
\*(FCprintf \*(FIfmt\*(FC, \*(FIexpr-list\*(FR
1043
1189
\*(CD\*(FCprint "hello" > \*(FIfile\*(FR
1045
Print data to \*(FIfile\fP. The first time the file is written to, it
1046
will be truncated. Subsequent commands append data.
1191
print data to \*(FIfile\fP. The first time the file is written to, it
1192
is truncated. Subsequent commands append data.
1048
1194
\*(FCprint "hello" >> \*(FIfile\*(FR
1050
Append data to \*(FIfile\fP. The previous contents of the file are not lost.
1196
append data to \*(FIfile\fP. The previous contents of \*(FIfile\*(FR are not lost.
1052
1198
\*(FCprint "hello" | \*(FIcmd\*(FR
1054
Print data down a pipeline to \*(FIcmd\*(FR.\*(CX
1200
print data down a pipeline to \*(FIcmd\*(FR.
1202
\*(CB\*(FCprint "hello" |& \*(FIcmd\*(FR
1204
print data down a pipeline to co-process \*(FIcmd\*(FR.\*(CX
1056
1206
.EB "\s+2\f(HBOUTPUT CONTROL\*(FR\s0"
1212
\*(CD\*(FCclose(\*(FIfile\*(FC)\*(FR
1214
close input or output file, pipe \*(CBor co-process.\*(CD
1216
\*(CB\*(FCclose(\*(FIcommand\*(FC, \*(FIhow\*(FC)\*(FR
1218
close one end of co-process pipe.
1219
Use \*(FC"to"\*(FR for the write end, or
1220
\*(FC"from"\*(FR for the read end.\*(CD
1223
On success, \*(FCclose()\*(FR returns zero for a file, or the exit status for a process.
1224
It returns \-1 if \*(FIfile\*(FR
1225
was never opened, or
1226
if there was a system problem.
1227
\*(CB\*(FCERRNO\*(FR describes
1229
.EB "\s+2\f(HBCLOSING REDIRECTIONS\*(FR\s0"
1061
1233
.\" --- Printf Formats
1188
1369
\*(CBThe following names are specific to \*(GK.
1193
\*(FC/dev/fd/\^\*(FIn\*(FR T{
1194
file associated with the open file descriptor \*(FIn\*(FR
1373
\*(FC/dev/fd/\^\*(FIn\*(FR
1375
File associated with the open file descriptor \*(FIn\*(FR.
1377
\*(FC/inet/tcp/\*(FIlport\*(FC/\*(FIrhost\*(FC/\*(FIrport\*(FR
1379
File for TCP/IP connection on local port \*(FIlport\*(FR to
1380
remote host \*(FIrhost\*(FR on remote port \*(FIrport\*(FR.
1381
Use a port of \*(FC0\*(FR to have the system pick a port.
1382
Usable only with the \*(FC|&\*(FR two-way I/O operator.
1384
\*(FC/inet/udp/\*(FIlport\*(FC/\*(FIrhost\*(FC/\*(FIrport\*(FR
1386
Similar, but use UDP/IP instead of TCP/IP.
1388
\*(CR\*(FC/inet/raw/\*(FIlport\*(FC/\*(FIrhost\*(FC/\*(FIrport\*(FR
1390
.\" Similar, but use raw IP sockets.
1391
Reserved for future use.\*(CB
1199
1395
Other special filenames provide access to information about the running
1266
1452
.\" --- Builtin String Functions
1457
\*(CB\*(FCasort(\*(FIs\*(FC \*(FR[\*(FC, \*(FId\*(FR]\*(FC)\*(FR
1459
sorts the source array \*(FIs\*(FR, replacing the indices with numeric
1460
values 1 through \*(FIn\*(FR (the number of elements in the array),
1461
and returns the number of elements.
1462
If destination \*(FId\*(FR is supplied, \*(FIs\*(FR is copied to \*(FId\*(FR,
1463
\*(FId\*(FR is sorted, and \*(FIs\*(FR is unchanged.\*(CD
1271
1465
\*(CB\*(FCgensub(\*(FIr\*(FC, \*(FIs\*(FC, \*(FIh \*(FR[\*(FC, \*(FIt\*(FR]\*(FC)\*(FR
1273
1467
search the target string
1274
1468
\*(FIt\fP for matches of the regular expression \*(FIr\*(FR. If
1275
1469
\*(FIh\fP is a string beginning with \*(FCg\fP or \*(FCG\*(FR,
1276
1470
replace all matches of \*(FIr\fP with \*(FIs\*(FR. Otherwise, \*(FIh\fP
1277
is a number indicating which match of \*(FIr\fP to replace. If no
1278
\*(FIt\fP is supplied, \*(FC$0\fP is used instead. Within the
1471
is a number indicating which match of \*(FIr\fP to replace.
1472
If \*(FIt\fP is not supplied, \*(FC$0\fP is used instead. Within the
1279
1473
replacement text \*(FIs\*(FR, the sequence \*(FC\e\*(FIn\*(FR,
1280
1474
where \*(FIn\fP is a digit from 1 to 9, may be used to indicate just
1281
1475
the text that matched the \*(FIn\*(FRth parenthesized subexpression.
1306
1500
returns the length of the string
1307
1501
\*(FIs\*(FR, or the length of \*(FC$0\fP if \*(FIs\fP is not supplied.
1309
\*(FCmatch(\*(FIs\*(FC, \*(FIr\*(FC)\*(FR
1503
\*(FCmatch(\*(FIs\*(FC, \*(FIr \*(CB\*(FR[\*(FC, \*(FIa\*(FR]\*(CD\*(FC)\*(FR
1311
1505
returns the position in
1312
1506
\*(FIs\fP where the regular expression \*(FIr\fP occurs, or 0 if
1313
1507
\*(FIr\fP is not present, and sets the values of variables
1315
1509
and \*(FCRLENGTH\*(FR.
1510
\*(CBIf \*(FIa\*(FR is supplied, the text matching all of \*(FIr\*(FR
1511
is placed in \*(FIa\*(FC[0]\*(FR. If there were parenthesized
1512
subexpressions, the matching texts are placed
1513
in \*(FIa\*(FC[1]\*(FR, \*(FIa\*(FC[2]\*(FR, and so on.\*(CD
1317
1515
\*(FCsplit(\*(FIs\*(FC, \*(FIa \*(FR[\*(FC, \*(FIr\*(FR]\*(FC)\*(FR
1397
1607
.EB "\s+2\f(HBTIME FUNCTIONS (\*(GK\f(HB)\*(FR\s0"
1609
.\" --- Builtin Bit Manipulation Functions
1613
provides the following functions for doing bitwise operations.
1618
\*(FCand(\*(FIv1\*(FC, \*(FIv2\*(FC)\*(FR
1620
returns the bitwise AND of the values provided by
1621
\*(FIv1\*(FR and \*(FIv2\*(FR.
1623
\*(FCcompl(\*(FIval\*(FC)\*(FR
1625
returns the bitwise complement of
1628
\*(FClshift(\*(FIval\*(FC, \*(FIcount\*(FC)\*(FR
1630
returns the value of \*(FIval\*(FR,
1631
shifted left by \*(FIcount\*(FR bits.
1633
\*(FCor(\*(FIv1\*(FC, \*(FIv2\*(FC)\*(FR
1635
returns the bitwise OR of the values provided by
1636
\*(FIv1\*(FR and \*(FIv2\*(FR.
1638
\*(FCrshift(\*(FIval\*(FC, \*(FIcount\*(FC)\*(FR
1640
returns the value of \*(FIval\*(FR,
1641
shifted right by \*(FIcount\*(FR bits.
1643
\*(FCxor(\*(FIv1\*(FC, \*(FIv2\*(FC)\*(FR
1645
teturns the bitwise XOR of the values provided by
1646
\*(FIv1\*(FR and \*(FIv2\*(FR.\*(CB
1648
.EB "\s+2\f(HBBIT MANIPULATION FUNCTIONS (\*(GK\f(HB)\*(FR\s0"
1650
.\" --- Builtin Internationalizatin Functions
1654
provides the following functions for runtime message translation.
1658
\*(FCbindtextdomain(\*(FIdirectory \*(FR[\*(FC, \*(FIdomain\*(FR]\*(FC)\*(FR
1660
specifies the directory where \*(GK looks for the \*(FC\&.mo\*(FR
1662
will not or cannot be placed in the ``standard'' locations
1663
(e.g., during testing.)
1664
It returns the directory where \*(FIdomain\*(FR is ``bound.''
1666
The default \*(FIdomain\*(FR is the value of \*(FCTEXTDOMAIN\*(FR.
1667
When \*(FIdirectory\*(FR is the null string (\*(FC"\^"\*(FR),
1668
\*(FCbindtextdomain()\*(FR returns the current binding for the
1669
given \*(FIdomain\*(FR.
1671
\*(FCdcgettext(\*(FIstring \*(FR[\*(FC, \*(FIdomain \*(FR[\*(FC, \*(FIcategory\*(FR]]\*(FC)\*(FR
1673
returns the translation of \*(FIstring\*(FR in text domain
1674
\*(FIdomain\*(FR for locale category \*(FIcategory\*(FR.
1675
The default value for \*(FIdomain\*(FR is the current value of \*(FCTEXTDOMAIN\*(FR.
1676
The default value for \*(FIcategory\*(FR is \*(FC"LC_MESSAGES"\*(FR.
1678
If you supply a value for \*(FIcategory\*(FR, it must be a string equal to
1679
one of the known locale categories.
1680
You must also supply a text domain. Use \*(FCTEXTDOMAIN\*(FR
1681
to use the current domain.\*(CB
1683
.EB "\s+2\f(HBINTERNATIONALIZATION (\*(GK\f(HB)\*(FR\s0"
1401
1687
.\" --- User-defined Functions
1450
1736
\*(CRNote: This usage is deprecated.\*(CX
1451
1737
.EB "\s+2\f(HBUSER-DEFINED FUNCTIONS\*(FR\s0"
1739
.\" --- Localization
1458
\*(CDIf you find a bug in this reference card, please report it via electronic
1459
mail to \*(FCarnold@gnu.org\*(FR.\*(CX
1460
.EB "\s+2\f(HBBUG REPORTS\*(FR\s0"
1742
\*(CDThere are several steps involved in producing and running a localizable
1745
1. Add a \*(FCBEGIN\*(FR action to assign a value to the
1746
\*(FCTEXTDOMAIN\*(FR variable to set the text domain for
1750
\*(FCBEGIN { TEXTDOMAIN = "myprog" }\*(FR
1752
This allows \*(GK to find the \*(FC\&.mo\*(FR
1753
file associated with your program.
1754
Without this step, \*(GK uses the \*(FCmessages\*(FR text domain,
1755
which probably won't work.
1757
2. Mark all strings that should be translated with leading underscores.
1759
3. Use the \*(FCdcgettext()\*(FR
1760
and/or \*(FCbindtextdomain()\*(FR
1761
functions in your program, as necessary or appropriate.
1766
\*(FCgawk \-\^\-gen\-po \-f myprog.awk > myprog.po\*(FR
1768
to generate a \*(FC\&.po\*(FR
1769
file for your program.
1771
5. Provide appropriate translations, and build and install a corresponding
1772
\*(FC\&.mo\*(FR file.
1774
The internationalization features are described in full detail in \*(AM.\*(CB
1775
.EB "\s+2\f(HBLOCALIZATION (\*(GK\f(HB)\*(FR\s0"
1785
\*(CD\*(FCextension(\*(FIlib\*(FC, \*(FIfunc\*(FC)\*(FR
1787
dynamically load the shared library
1791
in it to initialize the library.
1792
This adds new built-in functions to \*(GK.
1793
It returns the value returned by
1794
\*(FIfunc\*(FR.\*(CB
1796
.EB "\s+2\f(HBDYNAMIC EXTENSIONS (\*(GK\f(HB)\*(FR\s0"
1464
1798
.\" --- Environment Variables