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