]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/awk/awk.1
ssh: update to OpenSSH v8.8p1
[FreeBSD/FreeBSD.git] / usr.bin / awk / awk.1
1 .\"     $OpenBSD: awk.1,v 1.44 2015/09/14 20:06:58 schwarze Exp $
2 .\"
3 .\" Copyright (C) Lucent Technologies 1997
4 .\" All Rights Reserved
5 .\"
6 .\" Permission to use, copy, modify, and distribute this software and
7 .\" its documentation for any purpose and without fee is hereby
8 .\" granted, provided that the above copyright notice appear in all
9 .\" copies and that both that the copyright notice and this
10 .\" permission notice and warranty disclaimer appear in supporting
11 .\" documentation, and that the name Lucent Technologies or any of
12 .\" its entities not be used in advertising or publicity pertaining
13 .\" to distribution of the software without specific, written prior
14 .\" permission.
15 .\"
16 .\" LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 .\" INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
18 .\" IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
19 .\" SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
21 .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
22 .\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
23 .\" THIS SOFTWARE.
24 .\"
25 .\"     $FreeBSD$
26 .Dd July 30, 2021
27 .Dt AWK 1
28 .Os
29 .Sh NAME
30 .Nm awk
31 .Nd pattern-directed scanning and processing language
32 .Sh SYNOPSIS
33 .Nm awk
34 .Op Fl safe
35 .Op Fl version
36 .Op Fl d Ns Op Ar n
37 .Op Fl F Ar fs
38 .Op Fl v Ar var Ns = Ns Ar value
39 .Op Ar prog | Fl f Ar progfile
40 .Ar
41 .Sh DESCRIPTION
42 .Nm
43 scans each input
44 .Ar file
45 for lines that match any of a set of patterns specified literally in
46 .Ar prog
47 or in one or more files specified as
48 .Fl f Ar progfile .
49 With each pattern there can be an associated action that will be performed
50 when a line of a
51 .Ar file
52 matches the pattern.
53 Each line is matched against the
54 pattern portion of every pattern-action statement;
55 the associated action is performed for each matched pattern.
56 The file name
57 .Sq -
58 means the standard input.
59 Any
60 .Ar file
61 of the form
62 .Ar var Ns = Ns Ar value
63 is treated as an assignment, not a filename,
64 and is executed at the time it would have been opened if it were a filename.
65 .Pp
66 The options are as follows:
67 .Bl -tag -width "-safe "
68 .It Fl d Ns Op Ar n
69 Debug mode.
70 Set debug level to
71 .Ar n ,
72 or 1 if
73 .Ar n
74 is not specified.
75 A value greater than 1 causes
76 .Nm
77 to dump core on fatal errors.
78 .It Fl F Ar fs
79 Define the input field separator to be the regular expression
80 .Ar fs .
81 .It Fl f Ar progfile
82 Read program code from the specified file
83 .Ar progfile
84 instead of from the command line.
85 .It Fl safe
86 Disable file output
87 .Pf ( Ic print No > ,
88 .Ic print No >> ) ,
89 process creation
90 .Po
91 .Ar cmd | Ic getline ,
92 .Ic print | ,
93 .Ic system
94 .Pc
95 and access to the environment
96 .Pf ( Va ENVIRON ;
97 see the section on variables below).
98 This is a first
99 .Pq and not very reliable
100 approximation to a
101 .Dq safe
102 version of
103 .Nm .
104 .It Fl version
105 Print the version number of
106 .Nm
107 to standard output and exit.
108 .It Fl v Ar var Ns = Ns Ar value
109 Assign
110 .Ar value
111 to variable
112 .Ar var
113 before
114 .Ar prog
115 is executed;
116 any number of
117 .Fl v
118 options may be present.
119 .El
120 .Pp
121 The input is normally made up of input lines
122 .Pq records
123 separated by newlines, or by the value of
124 .Va RS .
125 If
126 .Va RS
127 is null, then any number of blank lines are used as the record separator,
128 and newlines are used as field separators
129 (in addition to the value of
130 .Va FS ) .
131 This is convenient when working with multi-line records.
132 .Pp
133 An input line is normally made up of fields separated by whitespace,
134 or by the extended regular expression
135 .Va FS
136 as described below.
137 The fields are denoted
138 .Va $1 , $2 , ... ,
139 while
140 .Va $0
141 refers to the entire line.
142 If
143 .Va FS
144 is null, the input line is split into one field per character.
145 While both gawk and mawk have the same behavior, it is unspecified in the
146 .St -p1003.1-2008
147 standard.
148 If
149 .Va FS
150 is a single space, then leading and trailing blank and newline characters are
151 skipped.
152 Fields are delimited by one or more blank or newline characters.
153 A blank character is a space or a tab.
154 If
155 .Va FS
156 is a single character, other than space, fields are delimited by each single
157 occurrence of that character.
158 The
159 .Va FS
160 variable defaults to a single space.
161 .Pp
162 Normally, any number of blanks separate fields.
163 In order to set the field separator to a single blank, use the
164 .Fl F
165 option with a value of
166 .Sq [\ \&] .
167 If a field separator of
168 .Sq t
169 is specified,
170 .Nm
171 treats it as if
172 .Sq \et
173 had been specified and uses
174 .Aq TAB
175 as the field separator.
176 In order to use a literal
177 .Sq t
178 as the field separator, use the
179 .Fl F
180 option with a value of
181 .Sq [t] .
182 .Pp
183 A pattern-action statement has the form
184 .Pp
185 .D1 Ar pattern Ic \&{ Ar action Ic \&}
186 .Pp
187 A missing
188 .Ic \&{ Ar action Ic \&}
189 means print the line;
190 a missing pattern always matches.
191 Pattern-action statements are separated by newlines or semicolons.
192 .Pp
193 Newlines are permitted after a terminating statement or following a comma
194 .Pq Sq ,\& ,
195 an open brace
196 .Pq Sq { ,
197 a logical AND
198 .Pq Sq && ,
199 a logical OR
200 .Pq Sq || ,
201 after the
202 .Sq do
203 or
204 .Sq else
205 keywords,
206 or after the closing parenthesis of an
207 .Sq if ,
208 .Sq for ,
209 or
210 .Sq while
211 statement.
212 Additionally, a backslash
213 .Pq Sq \e
214 can be used to escape a newline between tokens.
215 .Pp
216 An action is a sequence of statements.
217 A statement can be one of the following:
218 .Pp
219 .Bl -tag -width Ds -offset indent -compact
220 .It Ic if Ar ( expression ) Ar statement Op Ic else Ar statement
221 .It Ic while Ar ( expression ) Ar statement
222 .It Ic for Ar ( expression ; expression ; expression ) statement
223 .It Ic for Ar ( var Ic in Ar array ) statement
224 .It Ic do Ar statement Ic while Ar ( expression )
225 .It Ic break
226 .It Ic continue
227 .It Xo Ic {
228 .Op Ar statement ...
229 .Ic }
230 .Xc
231 .It Xo Ar expression
232 .No # commonly
233 .Ar var No = Ar expression
234 .Xc
235 .It Xo Ic print
236 .Op Ar expression-list
237 .Op > Ns Ar expression
238 .Xc
239 .It Xo Ic printf Ar format
240 .Op Ar ... , expression-list
241 .Op > Ns Ar expression
242 .Xc
243 .It Ic return Op Ar expression
244 .It Xo Ic next
245 .No # skip remaining patterns on this input line
246 .Xc
247 .It Xo Ic nextfile
248 .No # skip rest of this file, open next, start at top
249 .Xc
250 .It Xo Ic delete
251 .Sm off
252 .Ar array Ic \&[ Ar expression Ic \&]
253 .Sm on
254 .No # delete an array element
255 .Xc
256 .It Xo Ic delete Ar array
257 .No # delete all elements of array
258 .Xc
259 .It Xo Ic exit
260 .Op Ar expression
261 .No # exit immediately; status is Ar expression
262 .Xc
263 .El
264 .Pp
265 Statements are terminated by
266 semicolons, newlines or right braces.
267 An empty
268 .Ar expression-list
269 stands for
270 .Ar $0 .
271 String constants are quoted
272 .Li \&"" ,
273 with the usual C escapes recognized within
274 (see
275 .Xr printf 1
276 for a complete list of these).
277 Expressions take on string or numeric values as appropriate,
278 and are built using the operators
279 .Ic + \- * / % ^
280 .Pq exponentiation ,
281 and concatenation
282 .Pq indicated by whitespace .
283 The operators
284 .Ic \&! ++ \-\- += \-= *= /= %= ^=
285 .Ic > >= < <= == != ?\&:
286 are also available in expressions.
287 Variables may be scalars, array elements
288 (denoted
289 .Li x[i] )
290 or fields.
291 Variables are initialized to the null string.
292 Array subscripts may be any string,
293 not necessarily numeric;
294 this allows for a form of associative memory.
295 Multiple subscripts such as
296 .Li [i,j,k]
297 are permitted; the constituents are concatenated,
298 separated by the value of
299 .Va SUBSEP
300 .Pq see the section on variables below .
301 .Pp
302 The
303 .Ic print
304 statement prints its arguments on the standard output
305 (or on a file if
306 .Pf > Ar file
307 or
308 .Pf >> Ar file
309 is present or on a pipe if
310 .Pf |\ \& Ar cmd
311 is present), separated by the current output field separator,
312 and terminated by the output record separator.
313 .Ar file
314 and
315 .Ar cmd
316 may be literal names or parenthesized expressions;
317 identical string values in different statements denote
318 the same open file.
319 The
320 .Ic printf
321 statement formats its expression list according to the format
322 (see
323 .Xr printf 1 ) .
324 .Pp
325 Patterns are arbitrary Boolean combinations
326 (with
327 .Ic "\&! || &&" )
328 of regular expressions and
329 relational expressions.
330 .Nm
331 supports extended regular expressions
332 .Pq EREs .
333 See
334 .Xr re_format 7
335 for more information on regular expressions.
336 Isolated regular expressions
337 in a pattern apply to the entire line.
338 Regular expressions may also occur in
339 relational expressions, using the operators
340 .Ic ~
341 and
342 .Ic !~ .
343 .Pf / Ar re Ns /
344 is a constant regular expression;
345 any string (constant or variable) may be used
346 as a regular expression, except in the position of an isolated regular expression
347 in a pattern.
348 .Pp
349 A pattern may consist of two patterns separated by a comma;
350 in this case, the action is performed for all lines
351 from an occurrence of the first pattern
352 through an occurrence of the second.
353 .Pp
354 A relational expression is one of the following:
355 .Pp
356 .Bl -tag -width Ds -offset indent -compact
357 .It Ar expression matchop regular-expression
358 .It Ar expression relop expression
359 .It Ar expression Ic in Ar array-name
360 .It Xo Ic \&( Ns
361 .Ar expr , expr , \&... Ns Ic \&) in
362 .Ar array-name
363 .Xc
364 .El
365 .Pp
366 where a
367 .Ar relop
368 is any of the six relational operators in C, and a
369 .Ar matchop
370 is either
371 .Ic ~
372 (matches)
373 or
374 .Ic !~
375 (does not match).
376 A conditional is an arithmetic expression,
377 a relational expression,
378 or a Boolean combination
379 of these.
380 .Pp
381 The special patterns
382 .Ic BEGIN
383 and
384 .Ic END
385 may be used to capture control before the first input line is read
386 and after the last.
387 .Ic BEGIN
388 and
389 .Ic END
390 do not combine with other patterns.
391 .Pp
392 Variable names with special meanings:
393 .Pp
394 .Bl -tag -width "FILENAME " -compact
395 .It Va ARGC
396 Argument count, assignable.
397 .It Va ARGV
398 Argument array, assignable;
399 non-null members are taken as filenames.
400 .It Va CONVFMT
401 Conversion format when converting numbers
402 (default
403 .Qq Li %.6g ) .
404 .It Va ENVIRON
405 Array of environment variables; subscripts are names.
406 .It Va FILENAME
407 The name of the current input file.
408 .It Va FNR
409 Ordinal number of the current record in the current file.
410 .It Va FS
411 Regular expression used to separate fields; also settable
412 by option
413 .Fl F Ar fs .
414 .It Va NF
415 Number of fields in the current record.
416 .Va $NF
417 can be used to obtain the value of the last field in the current record.
418 .It Va NR
419 Ordinal number of the current record.
420 .It Va OFMT
421 Output format for numbers (default
422 .Qq Li %.6g ) .
423 .It Va OFS
424 Output field separator (default blank).
425 .It Va ORS
426 Output record separator (default newline).
427 .It Va RLENGTH
428 The length of the string matched by the
429 .Fn match
430 function.
431 .It Va RS
432 Input record separator (default newline).
433 .It Va RSTART
434 The starting position of the string matched by the
435 .Fn match
436 function.
437 .It Va SUBSEP
438 Separates multiple subscripts (default 034).
439 .El
440 .Sh FUNCTIONS
441 The awk language has a variety of built-in functions:
442 arithmetic, string, input/output, general, and bit-operation.
443 .Pp
444 Functions may be defined (at the position of a pattern-action statement)
445 thusly:
446 .Pp
447 .Dl function foo(a, b, c) { ...; return x }
448 .Pp
449 Parameters are passed by value if scalar, and by reference if array name;
450 functions may be called recursively.
451 Parameters are local to the function; all other variables are global.
452 Thus local variables may be created by providing excess parameters in
453 the function definition.
454 .Ss Arithmetic Functions
455 .Bl -tag -width "atan2(y, x)"
456 .It Fn atan2 y x
457 Return the arctangent of
458 .Fa y Ns / Ns Fa x
459 in radians.
460 .It Fn cos x
461 Return the cosine of
462 .Fa x ,
463 where
464 .Fa x
465 is in radians.
466 .It Fn exp x
467 Return the exponential of
468 .Fa x .
469 .It Fn int x
470 Return
471 .Fa x
472 truncated to an integer value.
473 .It Fn log x
474 Return the natural logarithm of
475 .Fa x .
476 .It Fn rand
477 Return a random number,
478 .Fa n ,
479 such that
480 .Sm off
481 .Pf 0 \*(Le Fa n No \*(Lt 1 .
482 .Sm on
483 .It Fn sin x
484 Return the sine of
485 .Fa x ,
486 where
487 .Fa x
488 is in radians.
489 .It Fn sqrt x
490 Return the square root of
491 .Fa x .
492 .It Fn srand expr
493 Sets seed for
494 .Fn rand
495 to
496 .Fa expr
497 and returns the previous seed.
498 If
499 .Fa expr
500 is omitted, the time of day is used instead.
501 .El
502 .Ss String Functions
503 .Bl -tag -width "split(s, a, fs)"
504 .It Fn gsub r t s
505 The same as
506 .Fn sub
507 except that all occurrences of the regular expression are replaced.
508 .Fn gsub
509 returns the number of replacements.
510 .It Fn index s t
511 The position in
512 .Fa s
513 where the string
514 .Fa t
515 occurs, or 0 if it does not.
516 .It Fn length s
517 The length of
518 .Fa s
519 taken as a string,
520 or of
521 .Va $0
522 if no argument is given.
523 .It Fn match s r
524 The position in
525 .Fa s
526 where the regular expression
527 .Fa r
528 occurs, or 0 if it does not.
529 The variable
530 .Va RSTART
531 is set to the starting position of the matched string
532 .Pq which is the same as the returned value
533 or zero if no match is found.
534 The variable
535 .Va RLENGTH
536 is set to the length of the matched string,
537 or \-1 if no match is found.
538 .It Fn split s a fs
539 Splits the string
540 .Fa s
541 into array elements
542 .Va a[1] , a[2] , ... , a[n]
543 and returns
544 .Va n .
545 The separation is done with the regular expression
546 .Ar fs
547 or with the field separator
548 .Va FS
549 if
550 .Ar fs
551 is not given.
552 An empty string as field separator splits the string
553 into one array element per character.
554 .It Fn sprintf fmt expr ...
555 The string resulting from formatting
556 .Fa expr , ...
557 according to the
558 .Xr printf 1
559 format
560 .Fa fmt .
561 .It Fn sub r t s
562 Substitutes
563 .Fa t
564 for the first occurrence of the regular expression
565 .Fa r
566 in the string
567 .Fa s .
568 If
569 .Fa s
570 is not given,
571 .Va $0
572 is used.
573 An ampersand
574 .Pq Sq &
575 in
576 .Fa t
577 is replaced in string
578 .Fa s
579 with regular expression
580 .Fa r .
581 A literal ampersand can be specified by preceding it with two backslashes
582 .Pq Sq \e\e .
583 A literal backslash can be specified by preceding it with another backslash
584 .Pq Sq \e\e .
585 .Fn sub
586 returns the number of replacements.
587 .It Fn substr s m n
588 Return at most the
589 .Fa n Ns -character
590 substring of
591 .Fa s
592 that begins at position
593 .Fa m
594 counted from 1.
595 If
596 .Fa n
597 is omitted, or if
598 .Fa n
599 specifies more characters than are left in the string,
600 the length of the substring is limited by the length of
601 .Fa s .
602 .It Fn tolower str
603 Returns a copy of
604 .Fa str
605 with all upper-case characters translated to their
606 corresponding lower-case equivalents.
607 .It Fn toupper str
608 Returns a copy of
609 .Fa str
610 with all lower-case characters translated to their
611 corresponding upper-case equivalents.
612 .El
613 .Ss Input/Output and General Functions
614 .Bl -tag -width "getline [var] < file"
615 .It Fn close expr
616 Closes the file or pipe
617 .Fa expr .
618 .Fa expr
619 should match the string that was used to open the file or pipe.
620 .It Ar cmd | Ic getline Op Va var
621 Read a record of input from a stream piped from the output of
622 .Ar cmd .
623 If
624 .Va var
625 is omitted, the variables
626 .Va $0
627 and
628 .Va NF
629 are set.
630 Otherwise
631 .Va var
632 is set.
633 If the stream is not open, it is opened.
634 As long as the stream remains open, subsequent calls
635 will read subsequent records from the stream.
636 The stream remains open until explicitly closed with a call to
637 .Fn close .
638 .Ic getline
639 returns 1 for a successful input, 0 for end of file, and \-1 for an error.
640 .It Fn fflush [expr]
641 Flushes any buffered output for the file or pipe
642 .Fa expr ,
643 or all open files or pipes if
644 .Fa expr
645 is omitted.
646 .Fa expr
647 should match the string that was used to open the file or pipe.
648 .It Ic getline
649 Sets
650 .Va $0
651 to the next input record from the current input file.
652 This form of
653 .Ic getline
654 sets the variables
655 .Va NF ,
656 .Va NR ,
657 and
658 .Va FNR .
659 .Ic getline
660 returns 1 for a successful input, 0 for end of file, and \-1 for an error.
661 .It Ic getline Va var
662 Sets
663 .Va $0
664 to variable
665 .Va var .
666 This form of
667 .Ic getline
668 sets the variables
669 .Va NR
670 and
671 .Va FNR .
672 .Ic getline
673 returns 1 for a successful input, 0 for end of file, and \-1 for an error.
674 .It Xo
675 .Ic getline Op Va var
676 .Pf \ \&< Ar file
677 .Xc
678 Sets
679 .Va $0
680 to the next record from
681 .Ar file .
682 If
683 .Va var
684 is omitted, the variables
685 .Va $0
686 and
687 .Va NF
688 are set.
689 Otherwise
690 .Va var
691 is set.
692 If
693 .Ar file
694 is not open, it is opened.
695 As long as the stream remains open, subsequent calls will read subsequent
696 records from
697 .Ar file .
698 .Ar file
699 remains open until explicitly closed with a call to
700 .Fn close .
701 .It Fn system cmd
702 Executes
703 .Fa cmd
704 and returns its exit status.
705 .El
706 .Ss Bit-Operation Functions
707 .Bl -tag -width "lshift(a, b)"
708 .It Fn compl x
709 Returns the bitwise complement of integer argument x.
710 .It Fn and v1 v2 ...
711 Performs a bitwise AND on all arguments provided, as integers.
712 There must be at least two values.
713 .It Fn or v1 v2 ...
714 Performs a bitwise OR on all arguments provided, as integers.
715 There must be at least two values.
716 .It Fn xor v1 v2 ...
717 Performs a bitwise Exclusive-OR on all arguments provided, as integers.
718 There must be at least two values.
719 .It Fn lshift x n
720 Returns integer argument x shifted by n bits to the left.
721 .It Fn rshift x n
722 Returns integer argument x shifted by n bits to the right.
723 .El
724 .Sh EXIT STATUS
725 .Ex -std awk
726 .Pp
727 But note that the
728 .Ic exit
729 expression can modify the exit status.
730 .Sh EXAMPLES
731 Print lines longer than 72 characters:
732 .Pp
733 .Dl length($0) > 72
734 .Pp
735 Print first two fields in opposite order:
736 .Pp
737 .Dl { print $2, $1 }
738 .Pp
739 Same, with input fields separated by comma and/or blanks and tabs:
740 .Bd -literal -offset indent
741 BEGIN { FS = ",[ \et]*|[ \et]+" }
742       { print $2, $1 }
743 .Ed
744 .Pp
745 Add up first column, print sum and average:
746 .Bd -literal -offset indent
747 { s += $1 }
748 END { print "sum is", s, " average is", s/NR }
749 .Ed
750 .Pp
751 Print all lines between start/stop pairs:
752 .Pp
753 .Dl /start/, /stop/
754 .Pp
755 Simulate echo(1):
756 .Bd -literal -offset indent
757 BEGIN { # Simulate echo(1)
758         for (i = 1; i < ARGC; i++) printf "%s ", ARGV[i]
759         printf "\en"
760         exit }
761 .Ed
762 .Pp
763 Print an error message to standard error:
764 .Bd -literal -offset indent
765 { print "error!" > "/dev/stderr" }
766 .Ed
767 .Sh SEE ALSO
768 .Xr cut 1 ,
769 .Xr lex 1 ,
770 .Xr printf 1 ,
771 .Xr sed 1 ,
772 .Xr re_format 7
773 .Rs
774 .%A A. V. Aho
775 .%A B. W. Kernighan
776 .%A P. J. Weinberger
777 .%T The AWK Programming Language
778 .%I Addison-Wesley
779 .%D 1988
780 .%O ISBN 0-201-07981-X
781 .Re
782 .Sh STANDARDS
783 The
784 .Nm
785 utility is compliant with the
786 .St -p1003.1-2008
787 specification,
788 except
789 .Nm
790 does not support {n,m} pattern matching.
791 .Pp
792 The flags
793 .Fl d ,
794 .Fl safe ,
795 and
796 .Fl version
797 as well as the commands
798 .Cm fflush , compl , and , or ,
799 .Cm xor , lshift , rshift ,
800 are extensions to that specification.
801 .Sh HISTORY
802 An
803 .Nm
804 utility appeared in
805 .At v7 .
806 .Sh BUGS
807 There are no explicit conversions between numbers and strings.
808 To force an expression to be treated as a number add 0 to it;
809 to force it to be treated as a string concatenate
810 .Li \&""
811 to it.
812 .Pp
813 The scope rules for variables in functions are a botch;
814 the syntax is worse.
815 .Sh DEPRECATED BEHAVIOR
816 One True Awk has accpeted
817 .Fl F Ar t
818 to mean the same as
819 .Fl F Ar <TAB>
820 to make it easier to specify tabs as the separator character.
821 Upstream One True Awk has deprecated this wart in the name of better
822 compatibility with other awk implementations like gawk and mawk.
823 .Pp
824 Historically,
825 .Nm
826 did not accept
827 .Dq 0x
828 as a hex string.
829 However, since One True Awk used strtod to convert strings to floats, and since
830 .Dq 0x12
831 is a valid hexadecimal representation of a floating point number,
832 On
833 .Fx ,
834 .Nm
835 has accepted this notation as an extension since One True Awk was imported in
836 .Fx 5.0 .
837 Upstream One True Awk has restored the historical behavior for better
838 compatibility between the different awk implementations.
839 Both gawk and mawk already behave similarly.
840 Starting with
841 .Fx 14.0
842 .Nm
843 will no longer accept this extension.
844 .Pp
845 The
846 .Fx
847 .Nm
848 sets the locale for many years to match the environment it was running in.
849 This lead to pattern ranges, like
850 .Dq "[A-Z]"
851 sometimes matching lower case characters in some locales.
852 This misbehavior was never in upstream One True Awk and has been removed as a
853 bug in
854 .Fx 12.3 ,
855 .Fx 13.1 ,
856 and
857 .Fx 14.0 .