{
    "mode": "man",
    "parameter": "nawk",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/nawk/1/json",
    "generated": "2026-09-04T02:13:15Z",
    "synopsis": "gawk [ POSIX or GNU style options ] -f program-file [ -- ] file ...\ngawk [ POSIX or GNU style options ] [ -- ] program-text file ...",
    "sections": {
        "NAME": {
            "content": "gawk - pattern scanning and processing language\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "gawk [ POSIX or GNU style options ] -f program-file [ -- ] file ...\ngawk [ POSIX or GNU style options ] [ -- ] program-text file ...\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Gawk is the GNU Project's implementation of the AWK programming language.  It conforms to the\ndefinition  of  the  language in the POSIX 1003.1 standard.  This version in turn is based on\nthe description in The AWK Programming Language, by Aho,  Kernighan,  and  Weinberger.   Gawk\nprovides  the  additional  features found in the current version of Brian Kernighan's awk and\nnumerous GNU-specific extensions.\n\nThe command line consists of options to gawk itself, the AWK program text  (if  not  supplied\nvia  the  -f or --include options), and values to be made available in the ARGC and ARGV pre-\ndefined AWK variables.\n",
            "subsections": []
        },
        "PREFACE": {
            "content": "This manual page is intentionally as terse as possible.  Full details are provided  in  GAWK:\nEffective  AWK Programming, and you should look there for the full story on any specific fea‐\nture.  Where possible, links to the online version of the manual are provided.\n",
            "subsections": []
        },
        "OPTION FORMAT": {
            "content": "Gawk options may be either traditional POSIX-style one letter options, or GNU-style long  op‐\ntions.   POSIX options start with a single “-”, while long options start with “--”.  Long op‐\ntions are provided for both GNU-specific features and for POSIX-mandated features.\n\nGawk-specific options are typically used in long-option form.  Arguments to long options  are\neither  joined  with the option by an = sign, with no intervening spaces, or they may be pro‐\nvided in the next command line argument.  Long options may be abbreviated, as long as the ab‐\nbreviation remains unique.\n\nAdditionally, every long option has a corresponding short option, so that the option's  func‐\ntionality may be used from within #!  executable scripts.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "Gawk  accepts  the following options.  Standard options are listed first, followed by options\nfor gawk extensions, listed alphabetically by short option.\n",
            "subsections": [
                {
                    "name": "-f _ --file _",
                    "content": "Read the AWK program source from the file program-file, instead of from the first com‐\nmand line argument.  Multiple -f options may be used.  Files read with -f are  treated\nas if they begin with an implicit @namespace \"awk\" statement.\n",
                    "flag": "-f",
                    "long": "--file"
                },
                {
                    "name": "-F _ --field-separator _",
                    "content": "Use fs for the input field separator (the value of the FS predefined variable).\n",
                    "flag": "-F",
                    "long": "--field-separator"
                },
                {
                    "name": "-v _ --assign _",
                    "content": "Assign  the  value  val  to  the variable var, before execution of the program begins.\nSuch variable values are available to the BEGIN rule of an AWK program.\n",
                    "flag": "-v",
                    "long": "--assign"
                },
                {
                    "name": "-b --characters-as-bytes",
                    "content": "Treat all input data as single-byte characters.  The  --posix  option  overrides  this\none.\n",
                    "flag": "-b",
                    "long": "--characters-as-bytes"
                },
                {
                    "name": "-c --traditional",
                    "content": "Run  in  compatibility mode.  In compatibility mode, gawk behaves identically to Brian\nKernighan's awk; none of the GNU-specific extensions are recognized.\n",
                    "flag": "-c",
                    "long": "--traditional"
                },
                {
                    "name": "-C --copyright",
                    "content": "Print the short version of the GNU copyright information message on the standard  out‐\nput and exit successfully.\n",
                    "flag": "-C",
                    "long": "--copyright"
                },
                {
                    "name": "-d --dump-variables",
                    "content": "Print  a  sorted  list of global variables, their types and final values to file.  The\ndefault file is awkvars.out in the current directory.\n",
                    "flag": "-d",
                    "long": "--dump-variables"
                },
                {
                    "name": "-D --debug",
                    "content": "Enable debugging of AWK programs.  By default, the debugger  reads  commands  interac‐\ntively  from  the  keyboard  (standard input).  The optional file argument specifies a\nfile with a list of commands for the debugger to execute non-interactively.\nIn this mode of execution, gawk loads the AWK source code and then prompts for  debug‐\nging  commands.  Gawk can only debug AWK program source provided with the -f and --in‐\nclude options.  The debugger is documented in GAWK:  Effective  AWK  Programming;  see\nhttps://www.gnu.org/software/gawk/manual/htmlnode/Debugger.html#Debugger.\n",
                    "flag": "-D",
                    "long": "--debug"
                },
                {
                    "name": "-e _ --source _",
                    "content": "Use program-text as AWK program source code.  Each argument supplied via -e is treated\nas if it begins with an implicit @namespace \"awk\" statement.\n",
                    "flag": "-e",
                    "long": "--source"
                },
                {
                    "name": "-E _ --exec _",
                    "content": "Similar to -f, however, this is option is the last one processed.  This should be used\nwith  #!   scripts,  particularly for CGI applications, to avoid passing in options or\nsource code (!) on the command line from a URL.   This  option  disables  command-line\nvariable assignments.\n",
                    "flag": "-E",
                    "long": "--exec"
                },
                {
                    "name": "-g --gen-pot",
                    "content": "Scan  and  parse  the  AWK program, and generate a GNU .pot (Portable Object Template)\nformat file on standard output with entries for all localizable strings  in  the  pro‐\ngram.  The program itself is not executed.\n",
                    "flag": "-g",
                    "long": "--gen-pot"
                },
                {
                    "name": "-h --help",
                    "content": "Print a relatively short summary of the available options on the standard output.  Per\nthe GNU Coding Standards, these options cause an immediate, successful exit.\n",
                    "flag": "-h",
                    "long": "--help"
                },
                {
                    "name": "-i _ --include _",
                    "content": "Load  an awk source library.  This searches for the library using the AWKPATH environ‐\nment variable.  If the initial search fails, another attempt will be  made  after  ap‐\npending  the  .awk  suffix.   The  file will be loaded only once (i.e., duplicates are\neliminated), and the code does not constitute the main  program  source.   Files  read\nwith  --include  are treated as if they begin with an implicit @namespace \"awk\" state‐\nment.\n",
                    "flag": "-i",
                    "long": "--include"
                },
                {
                    "name": "-I --trace",
                    "content": "Print the internal byte code names as they are executed when running the program.  The\ntrace  is  printed  to standard error. Each ``op code'' is preceded by a + sign in the\noutput.\n",
                    "flag": "-I",
                    "long": "--trace"
                },
                {
                    "name": "-l _ --load _",
                    "content": "Load a gawk extension from the shared library lib.  This searches for the library  us‐\ning the AWKLIBPATH environment variable.  If the initial search fails, another attempt\nwill  be made after appending the default shared library suffix for the platform.  The\nlibrary initialization routine is expected to be named dlload().\n",
                    "flag": "-l",
                    "long": "--load"
                },
                {
                    "name": "-L  --lint",
                    "content": "Provide warnings about constructs that are dubious or non-portable to other AWK imple‐\nmentations.   See  https://www.gnu.org/software/gawk/manual/htmlnode/Options.html#Op‐\ntions for the list of possible values for value.\n",
                    "flag": "-L",
                    "long": "--lint"
                },
                {
                    "name": "-M --bignum",
                    "content": "Force  arbitrary precision arithmetic on numbers. This option has no effect if gawk is\nnot compiled to use the GNU MPFR and GMP libraries.  (In such a case,  gawk  issues  a\nwarning.)\n\nNOTE:  This feature is on parole.  The primary gawk maintainer is no longer supporting\nit, although there is a member of the development  team  who  is.  If  this  situation\nchanges, the feature will be removed from gawk.\n",
                    "flag": "-M",
                    "long": "--bignum"
                },
                {
                    "name": "-n --non-decimal-data",
                    "content": "Recognize octal and hexadecimal values in input data.  Use this option with great cau‐\ntion!\n",
                    "flag": "-n",
                    "long": "--non-decimal-data"
                },
                {
                    "name": "-N --use-lc-numeric",
                    "content": "Force gawk to use the locale's decimal point character when parsing input data.\n",
                    "flag": "-N",
                    "long": "--use-lc-numeric"
                },
                {
                    "name": "-o --pretty-print",
                    "content": "Output  a  pretty  printed  version  of  the  program  to  file.   The default file is\nawkprof.out in the current directory.  This option implies --no-optimize.\n",
                    "flag": "-o",
                    "long": "--pretty-print"
                },
                {
                    "name": "-O --optimize",
                    "content": "Enable gawk's default optimizations upon the internal representation of  the  program.\nThis option is on by default.\n",
                    "flag": "-O",
                    "long": "--optimize"
                },
                {
                    "name": "-p --profile",
                    "content": "Start  a  profiling session, and send the profiling data to prof-file.  The default is\nawkprof.out in the current directory.  The profile contains execution counts  of  each\nstatement in the program in the left margin and function call counts for each user-de‐\nfined  function.   Gawk runs more slowly in this mode.  This option implies --no-opti‐\nmize.\n",
                    "flag": "-p",
                    "long": "--profile"
                },
                {
                    "name": "-P --posix",
                    "content": "This turns on compatibility mode, and disables a number of common extensions.\n",
                    "flag": "-P",
                    "long": "--posix"
                },
                {
                    "name": "-r --re-interval",
                    "content": "Enable the use of interval expressions in regular expression matching.   Interval  ex‐\npressions are enabled by default, but this option remains for backwards compatibility.\n",
                    "flag": "-r",
                    "long": "--re-interval"
                },
                {
                    "name": "-s --no-optimize",
                    "content": "Disable gawk's default optimizations upon the internal representation of the program.\n",
                    "flag": "-s",
                    "long": "--no-optimize"
                },
                {
                    "name": "-S --sandbox",
                    "content": "Run gawk in sandbox mode, disabling the system() function, input redirection with get‐\nline,  output redirection with print and printf, and loading dynamic extensions.  Com‐\nmand execution (through pipelines) is also disabled.\n",
                    "flag": "-S",
                    "long": "--sandbox"
                },
                {
                    "name": "-t --lint-old",
                    "content": "Provide warnings about constructs that are not portable to  the  original  version  of\nUNIX awk.\n",
                    "flag": "-t",
                    "long": "--lint-old"
                },
                {
                    "name": "-V --version",
                    "content": "Print  version  information  for  this particular copy of gawk on the standard output.\nThis is useful when reporting bugs.  Per the GNU Coding Standards, these options cause\nan immediate, successful exit.\n\n--     Signal the end of options. This is useful to allow further arguments to the  AWK  pro‐\ngram itself to start with a “-”.\n\nIn  compatibility  mode, any other options are flagged as invalid, but are otherwise ignored.\nIn normal operation, as long as program text has been supplied, unknown options are passed on\nto the AWK program in the ARGV array for processing.\n\nFor POSIX compatibility, the -W option may be used, followed by the name of a long option.\n",
                    "flag": "-V",
                    "long": "--version"
                }
            ]
        },
        "AWK PROGRAM EXECUTION": {
            "content": "An AWK program consists of a sequence of optional directives, pattern-action statements,  and\noptional function definitions.\n\n@include \"filename\"\n@load \"filename\"\n@namespace \"name\"\npattern   { action statements }\nfunction name(parameter list) { statements }\n\nGawk  first reads the program source from the program-file(s) if specified, from arguments to\n--source, or from the first non-option argument on the command line.  The -f and --source op‐\ntions may be used multiple times on the command line.  Gawk reads the program text as if  all\nthe program-files and command line source texts had been concatenated together.\n\nIn  addition,  lines  beginning  with @include may be used to include other source files into\nyour program.  This is equivalent to using the --include option.\n\nLines beginning with @load may be used to load extension functions into your  program.   This\nis equivalent to using the --load option.\n\nThe  environment  variable  AWKPATH  specifies a search path to use when finding source files\nnamed with the -f and --include options.  If this variable does not exist, the  default  path\nis  \".:/usr/local/share/awk\".   (The  actual  directory may vary, depending upon how gawk was\nbuilt and installed.)  If a file name given to the -f option contains  a  “/”  character,  no\npath search is performed.\n\nThe  environment variable AWKLIBPATH specifies a search path to use when finding source files\nnamed with the --load option.  If this variable does not exist, the default path is \"/usr/lo‐\ncal/lib/gawk\".  (The actual directory may vary, depending upon how gawk  was  built  and  in‐\nstalled.)\n\nGawk executes AWK programs in the following order.  First, all variable assignments specified\nvia  the  -v  option  are  performed.  Next, gawk compiles the program into an internal form.\nThen, gawk executes the code in the BEGIN rule(s) (if any), and then proceeds  to  read  each\nfile  named  in the ARGV array (up to ARGV[ARGC-1]).  If there are no files named on the com‐\nmand line, gawk reads the standard input.\n\nIf a filename on the command line has the form var=val it is treated as  a  variable  assign‐\nment.   The  variable  var  will  be  assigned  the value val.  (This happens after any BEGIN\nrule(s) have been run.)\n\nIf the value of a particular element of ARGV is empty (\"\"), gawk skips over it.\n\nFor each input file, if a BEGINFILE rule exists, gawk executes  the  associated  code  before\nprocessing  the  contents of the file. Similarly, gawk executes the code associated with END‐\nFILE rules after processing the file.\n\nFor each record in the input, gawk tests to see if it matches any pattern in the AWK program.\nFor each pattern that the record matches, gawk executes the associated action.  The  patterns\nare tested in the order they occur in the program.\n\nFinally,  after  all  the  input  is exhausted, gawk executes the code in the END rule(s) (if\nany).\n",
            "subsections": [
                {
                    "name": "Command Line Directories",
                    "content": "According to POSIX, files named on the awk command line must be text files.  The behavior  is\n``undefined'' if they are not.  Most versions of awk treat a directory on the command line as\na fatal error.\n\nFor  gawk,  a directory on the command line produces a warning, but is otherwise skipped.  If\neither of the --posix or --traditional options is given, then gawk reverts to treating direc‐\ntories on the command line as a fatal error.\n\nVARIABLES, RECORDS AND FIELDS\nAWK variables are dynamic; they come into existence when they are first used.   Their  values\nare either floating-point numbers or strings, or both, depending upon how they are used.  Ad‐\nditionally,  gawk  allows variables to have regular-expression type.  AWK also has one dimen‐\nsional arrays; arrays with multiple dimensions may be simulated.  However, gawk provides true\narrays of arrays.  Several pre-defined variables are set as a program  runs;  these  are  de‐\nscribed as needed and summarized below.\n"
                },
                {
                    "name": "Records",
                    "content": "Normally, records are separated by newline characters.  You can control how records are sepa‐\nrated  by  assigning  values  to  the  built-in  variable  RS.  See https://www.gnu.org/soft‐\nware/gawk/manual/htmlnode/Records.html for the details.\n"
                },
                {
                    "name": "Fields",
                    "content": "As each input record is read, gawk splits the record into fields, using the value of  the  FS\nvariable  as  the field separator.  Additionally, FIELDWIDTHS and FPAT may be used to control\ninput field splitting.  See the details, starting  at  https://www.gnu.org/software/gawk/man‐\nual/htmlnode/Fields.html.\n\nEach  field  in the input record may be referenced by its position: $1, $2, and so on.  $0 is\nthe whole record, including leading and trailing whitespace.\n\nThe variable NF is set to the total number of fields in the input record.\n\nReferences to non-existent fields (i.e., fields after $NF) produce the null string.  However,\nassigning to a non-existent field (e.g., $(NF+2) = 5) increases the value of NF, creates  any\nintervening fields with the null string as their values, and causes the value of $0 to be re‐\ncomputed,  with  the fields being separated by the value of OFS.  References to negative num‐\nbered fields cause a fatal error.  Decrementing NF causes the values of fields past  the  new\nvalue  to  be  lost, and the value of $0 to be recomputed, with the fields being separated by\nthe value of OFS.\n\nAssigning a value to an existing field causes the whole record to be rebuilt when $0 is  ref‐\nerenced.   Similarly,  assigning  a value to $0 causes the record to be resplit, creating new\nvalues for the fields.\n"
                },
                {
                    "name": "Built-in Variables",
                    "content": "Gawk's built-in variables are listed below.  This list is purposely terse. For  details,  see\nhttps://www.gnu.org/software/gawk/manual/htmlnode/Built002din-Variables.\n\nARGC        The number of command line arguments.\n\nARGIND      The index in ARGV of the current file being processed.\n\nARGV        Array of command line arguments.  The array is indexed from 0 to ARGC - 1.\n\nBINMODE     On  non-POSIX  systems,  specifies  use  of  “binary” mode for all file I/O.  See\nhttps://www.gnu.org/software/gawk/manual/htmlnode/PC-Using.html for the details.\n\nCONVFMT     The conversion format for numbers, \"%.6g\", by default.\n\nENVIRON     An array containing the values of the current environment.  The array is  indexed\nby the environment variables, each element being the value of that variable.\n\nERRNO       If  a  system  error occurs either doing a redirection for getline, during a read\nfor getline, or during a close(), then ERRNO is set to a  string  describing  the\nerror.  The value is subject to translation in non-English locales.\n\nFIELDWIDTHS A  whitespace-separated  list  of  field widths.  When set, gawk parses the input\ninto fields of fixed width, instead of using the value of the FS variable as  the\nfield  separator.   Each  field width may optionally be preceded by a colon-sepa‐\nrated value specifying the number of characters to skip before the field starts.\n\nFILENAME    The name of the current input file.  If no files are  specified  on  the  command\nline,  the  value  of FILENAME is “-”.  However, FILENAME is undefined inside the\nBEGIN rule (unless set by getline).\n\nFNR         The input record number in the current input file.\n\nFPAT        A regular expression describing the contents of the fields  in  a  record.   When\nset,  gawk  parses  the input into fields, where the fields match the regular ex‐\npression, instead of using the value of FS as the field separator.\n\nFS          The input field separator, a space  by  default.   See  https://www.gnu.org/soft‐\nware/gawk/manual/htmlnode/Field-Separators.html for the details.\n\nFUNCTAB     An array whose indices and corresponding values are the names of all the user-de‐\nfined  or  extension  functions in the program.  NOTE: You may not use the delete\nstatement with the FUNCTAB array.\n\nIGNORECASE  Controls the case-sensitivity of all regular expression  and  string  operations.\nSee  https://www.gnu.org/software/gawk/manual/htmlnode/Case002dsensitivity.html\nfor details.\n\nLINT        Provides dynamic control of the --lint option from within an AWK program.\n\nNF          The number of fields in the current input record.\n\nNR          The total number of input records seen so far.\n\nOFMT        The output format for numbers, \"%.6g\", by default.\n\nOFS         The output field separator, a space by default.\n\nORS         The output record separator, by default a newline.\n\nPREC        The working precision of arbitrary precision floating-point numbers,  53  by  de‐\nfault.\n\nPROCINFO    The  elements  of  this array provide access to information about the running AWK\nprogram.  See https://www.gnu.org/software/gawk/manual/htmlnode/Auto002dset for\nthe details.\n\nROUNDMODE   The rounding mode to use for arbitrary precision arithmetic on  numbers,  by  de‐\nfault   \"N\"   (IEEE-754  roundTiesToEven  mode).   See  https://www.gnu.org/soft‐\nware/gawk/manual/htmlnode/Setting-the-rounding-mode for the details.\n\nRS          The input record separator, by default a newline.\n\nRT          The record terminator.  Gawk sets RT to the input text that matched the character\nor regular expression specified by RS.\n\nRSTART      The index of the first character matched by match(); 0 if no match.\n\nRLENGTH     The length of the string matched by match(); -1 if no match.\n\nSUBSEP      The string used to separate multiple subscripts in  array  elements,  by  default\n\"\\034\".\n\nSYMTAB      An  array  whose  indices are the names of all currently defined global variables\nand arrays in the program.  You may not use the delete statement with the  SYMTAB\narray, nor assign to elements with an index that is not a variable name.\n\nTEXTDOMAIN  The  text  domain of the AWK program; used to find the localized translations for\nthe program's strings.\n"
                },
                {
                    "name": "Arrays",
                    "content": "Arrays are subscripted with an expression between square brackets ([ and ]).  If the  expres‐\nsion  is an expression list (expr, expr ...)  then the array subscript is a string consisting\nof the concatenation of the (string) value of each expression, separated by the value of  the\nSUBSEP  variable.   This facility is used to simulate multiply dimensioned arrays.  For exam‐\nple:\n\ni = \"A\"; j = \"B\"; k = \"C\"\nx[i, j, k] = \"hello, world\\n\"\n\nassigns the string \"hello, world\\n\" to the element of the array x which  is  indexed  by  the\nstring \"A\\034B\\034C\".  All arrays in AWK are associative, i.e., indexed by string values.\n\nThe special operator in may be used to test if an array has an index consisting of a particu‐\nlar value:\n\nif (val in array)\nprint array[val]\n\nIf the array has multiple subscripts, use (i, j) in array.\n\nThe in construct may also be used in a for loop to iterate over all the elements of an array.\nHowever, the (i, j) in array construct only works in tests, not in for loops.\n\nAn element may be deleted from an array using the delete statement.  The delete statement may\nalso  be  used  to  delete the entire contents of an array, just by specifying the array name\nwithout a subscript.\n\ngawk supports true multidimensional arrays. It does not require that such arrays be ``rectan‐\ngular'' as in C or C++.   See  https://www.gnu.org/software/gawk/manual/htmlnode/Arrays  for\ndetails.\n"
                },
                {
                    "name": "Namespaces",
                    "content": "Gawk  provides a simple namespace facility to help work around the fact that all variables in\nAWK are global.\n\nA qualified name consists of a two simple identifiers joined by a  double  colon  (::).   The\nleft-hand  identifier  represents the namespace and the right-hand identifier is the variable\nwithin it.  All simple (non-qualified) names are considered to be in  the  ``current''  name‐\nspace; the default namespace is awk.  However, simple identifiers consisting solely of upper‐\ncase letters are forced into the awk namespace, even if the current namespace is different.\n\nYou change the current namespace with an @namespace \"name\" directive.\n\nThe standard predefined builtin function names may not be used as namespace names.  The names\nof  additional functions provided by gawk may be used as namespace names or as simple identi‐\nfiers in other namespaces.   For  more  details,  see  https://www.gnu.org/software/gawk/man‐\nual/htmlnode/Namespaces.html#Namespaces.\n"
                },
                {
                    "name": "Variable Typing And Conversion",
                    "content": "Variables  and fields may be (floating point) numbers, or strings, or both.  They may also be\nregular expressions. How the value of a variable is interpreted depends upon its context.  If\nused in a numeric expression, it will be treated as a number; if used as a string it will  be\ntreated as a string.\n\nTo force a variable to be treated as a number, add zero to it; to force it to be treated as a\nstring, concatenate it with the null string.\n\nUninitialized  variables  have  the  numeric value zero and the string value \"\" (the null, or\nempty, string).\n\nWhen a string must be converted to a number, the conversion is accomplished using  strtod(3).\nA  number  is  converted  to  a  string  by using the value of CONVFMT as a format string for\nsprintf(3), with the numeric value of the variable as the argument.  However, even though all\nnumbers in AWK are floating-point, integral values are always converted as integers.\n\nGawk performs comparisons as follows: If two variables are numeric, they are compared numeri‐\ncally.  If one value is numeric and the other has a string value that is a “numeric  string,”\nthen  comparisons  are also done numerically.  Otherwise, the numeric value is converted to a\nstring and a string comparison is  performed.   Two  strings  are  compared,  of  course,  as\nstrings.\n\nNote that string constants, such as \"57\", are not numeric strings, they are string constants.\nThe  idea of “numeric string” only applies to fields, getline input, FILENAME, ARGV elements,\nENVIRON elements and the elements of an array created by split() or patsplit() that  are  nu‐\nmeric  strings.   The basic idea is that user input, and only user input, that looks numeric,\nshould be treated that way.\n"
                },
                {
                    "name": "Octal and Hexadecimal Constants",
                    "content": "You may use C-style octal and hexadecimal constants in your AWK program source code.  For ex‐\nample, the octal value 011 is equal to decimal 9, and the hexadecimal value 0x11 is equal  to\ndecimal 17.\n"
                },
                {
                    "name": "String Constants",
                    "content": "String  constants  in  AWK  are  sequences of characters enclosed between double quotes (like\n\"value\").   Within  strings,  certain  escape  sequences  are  recognized,  as  in  C.    See\nhttps://www.gnu.org/software/gawk/manual/htmlnode/Escape-Sequences for the details.\n"
                },
                {
                    "name": "Regexp Constants",
                    "content": "A  regular  expression  constant is a sequence of characters enclosed between forward slashes\n(like /value/).\n\nThe escape sequences described in the manual may also be used inside constant regular expres‐\nsions (e.g., /[ \\t\\f\\n\\r\\v]/ matches whitespace characters).\n\nGawk provides strongly typed regular expression constants. These are written with a leading @\nsymbol (like so: @/value/).  Such constants may be assigned to scalars (variables, array ele‐\nments) and passed to user-defined functions. Variables that have been so assigned have  regu‐\nlar expression type.\n"
                }
            ]
        },
        "PATTERNS AND ACTIONS": {
            "content": "AWK  is  a  line-oriented  language.   The  pattern comes first, and then the action.  Action\nstatements are enclosed in { and }.  Either the pattern may be missing, or the action may  be\nmissing,  but, of course, not both.  If the pattern is missing, the action executes for every\nsingle record of input.  A missing action is equivalent to\n\n{ print }\n\nwhich prints the entire record.\n\nComments begin with the # character, and continue until the end of the line.  Empty lines may\nbe used to separate statements.  Normally, a statement ends with a newline, however, this  is\nnot  the  case  for  lines ending in a comma, {, ?, :, &&, or ||.  Lines ending in do or else\nalso have their statements automatically continued on the following line.  In other cases,  a\nline  can  be  continued by ending it with a “\\”, in which case the newline is ignored.  How‐\never, a “\\” after a # is not special.\n\nMultiple statements may be put on one line by separating them with a “;”.   This  applies  to\nboth  the statements within the action part of a pattern-action pair (the usual case), and to\nthe pattern-action statements themselves.\n",
            "subsections": [
                {
                    "name": "Patterns",
                    "content": "AWK patterns may be one of the following:\n\nBEGIN\nEND\nBEGINFILE\nENDFILE\n/regular expression/\nrelational expression\npattern && pattern\npattern || pattern\npattern ? pattern : pattern\n(pattern)\n! pattern\npattern1, pattern2\n\nBEGIN and END are two special kinds of patterns which are not tested against the input.   The\naction  parts of all BEGIN patterns are merged as if all the statements had been written in a\nsingle BEGIN rule.  They are executed before any of the input is read.   Similarly,  all  the\nEND rules are merged, and executed when all the input is exhausted (or when an exit statement\nis  executed).   BEGIN and END patterns cannot be combined with other patterns in pattern ex‐\npressions.  BEGIN and END patterns cannot have missing action parts.\n\nBEGINFILE and ENDFILE are additional special patterns whose actions are executed before read‐\ning the first record of each command-line input file and after reading  the  last  record  of\neach file.  Inside the BEGINFILE rule, the value of ERRNO is the empty string if the file was\nopened  successfully.  Otherwise, there is some problem with the file and the code should use\nnextfile to skip it. If that is not done, gawk produces its usual fatal error for files  that\ncannot be opened.\n\nFor /regular expression/ patterns, the associated statement is executed for each input record\nthat  matches  the regular expression.  Regular expressions are essentially the same as those\nin egrep(1).  See https://www.gnu.org/software/gawk/manual/htmlnode/Regexp.html for the  de‐\ntails on regular expressions.\n\nA relational expression may use any of the operators defined below in the section on actions.\nThese generally test whether certain fields match certain regular expressions.\n\nThe  &&,  ||, and !  operators are logical AND, logical OR, and logical NOT, respectively, as\nin C.  They do short-circuit evaluation, also as in C, and are used for combining more primi‐\ntive pattern expressions.  As in most languages, parentheses may be used to change the  order\nof evaluation.\n\nThe  ?:  operator is like the same operator in C.  If the first pattern is true then the pat‐\ntern used for testing is the second pattern, otherwise it is the third.  Only one of the sec‐\nond and third patterns is evaluated.\n\nThe pattern1, pattern2 form of an expression is called a range pattern.  It matches all input\nrecords starting with a record that matches pattern1, and  continuing  until  a  record  that\nmatches pattern2, inclusive.  It does not combine with any other sort of pattern expression.\n"
                },
                {
                    "name": "Actions",
                    "content": "Action  statements  are  enclosed in braces, { and }.  Action statements consist of the usual\nassignment, conditional, and looping statements found in most languages.  The operators, con‐\ntrol statements, and input/output statements available are patterned after those in C.\n"
                },
                {
                    "name": "Operators",
                    "content": "The operators in AWK, in order of decreasing precedence, are:\n\n(...)       Grouping\n\n$           Field reference.\n\n++ --       Increment and decrement, both prefix and postfix.\n\n^           Exponentiation.\n\n+ - !       Unary plus, unary minus, and logical negation.\n\n* / %       Multiplication, division, and modulus.\n\n+ -         Addition and subtraction.\n\nspace       String concatenation.\n\n|   |&      Piped I/O for getline, print, and printf.\n"
                },
                {
                    "name": "< > <= >= == !=",
                    "content": "The regular relational operators.\n\n~ !~        Regular expression match, negated match.\n\nin          Array membership.\n\n&&          Logical AND.\n\n||          Logical OR.\n\n?:          The C conditional expression.  This has the form expr1 ? expr2 : expr3.  If expr1\nis true, the value of the expression is expr2, otherwise it is expr3.   Only  one\nof expr2 and expr3 is evaluated.\n\n= += -= *= /= %= ^=\nAssignment.   Both absolute assignment (var = value) and operator-assignment (the\nother forms) are supported.\n"
                },
                {
                    "name": "Control Statements",
                    "content": "The control statements are as follows:\n\nif (condition) statement [ else statement ]\nwhile (condition) statement\ndo statement while (condition)\nfor (expr1; expr2; expr3) statement\nfor (var in array) statement\nbreak\ncontinue\ndelete array[index]\ndelete array\nexit [ expression ]\n{ statements }\nswitch (expression) {\ncase value|regex : statement\n...\n[ default: statement ]\n}\n"
                },
                {
                    "name": "I/O Statements",
                    "content": "The input/output statements are as follows:\n\nclose(file [, how])   Close an open file, pipe or coprocess.  The optional how should only be\nused when closing one end of a two-way pipe to a coprocess.  It must be\na string value, either \"to\" or \"from\".\n\ngetline               Set $0 from the next input record; set NF, NR, FNR, RT.\n\ngetline <file         Set $0 from the next record of file; set NF, RT.\n\ngetline var           Set var from the next input record; set NR, FNR, RT.\n\ngetline var <file     Set var from the next record of file; set RT.\n\ncommand | getline [var]\nRun command, piping the output either into $0 or var, as above, and RT.\n\ncommand |& getline [var]\nRun command as a coprocess piping the output either into $0 or var,  as\nabove,  and RT.  (The command can also be a socket.  See the subsection\nSpecial File Names, below.)\n\nfflush([file])        Flush any buffers associated with the open output file  or  pipe  file.\nIf  file  is  missing  or if it is the null string, then flush all open\noutput files and pipes.\n\nnext                  Stop processing the current input record.  Read the next  input  record\nand  start  processing  over with the first pattern in the AWK program.\nUpon reaching the end of the input data, execute any END rule(s).\n\nnextfile              Stop processing the current input file.  The  next  input  record  read\ncomes  from the next input file.  Update FILENAME and ARGIND, reset FNR\nto 1, and start processing over with the first pattern in the AWK  pro‐\ngram.  Upon reaching the end of the input data, execute any ENDFILE and\nEND rule(s).\n\nprint                 Print  the  current  record.   The output record is terminated with the\nvalue of ORS.\n\nprint expr-list       Print expressions.  Each expression is separated by the value  of  OFS.\nThe output record is terminated with the value of ORS.\n\nprint expr-list >file Print  expressions  on file.  Each expression is separated by the value\nof OFS.  The output record is terminated with the value of ORS.\n\nprintf fmt, expr-list Format and print.\n\nprintf fmt, expr-list >file\nFormat and print on file.\n\nsystem(cmd-line)      Execute the command cmd-line, and return the exit  status.   (This  may\nnot  be available on non-POSIX systems.)  See https://www.gnu.org/soft‐\nware/gawk/manual/htmlnode/I002fO-Functions.html#I002fO-Functions for\nthe full details on the exit status.\n\nAdditional output redirections are allowed for print and printf.\n\nprint ... >> file\nAppend output to the file.\n\nprint ... | command\nWrite on a pipe.\n\nprint ... |& command\nSend data to a coprocess or socket.  (See also the subsection Special File Names,  be‐\nlow.)\n\nThe  getline  command  returns 1 on success, zero on end of file, and -1 on an error.  If the\nerrno(3) value indicates that  the  I/O  operation  may  be  retried,  and  PROCINFO[\"input\",\n\"RETRY\"]  is  set, then -2 is returned instead of -1, and further calls to getline may be at‐\ntempted.  Upon an error, ERRNO is set to a string describing the problem.\n\nNOTE: Failure in opening a two-way socket results in a non-fatal error being returned to  the\ncalling  function.  If using a pipe, coprocess, or socket to getline, or from print or printf\nwithin a loop, you must use close() to create new instances of the command  or  socket.   AWK\ndoes not automatically close pipes, sockets, or coprocesses when they return EOF.\n\nThe  AWK  versions  of the printf statement and sprintf() function are similar to those of C.\nFor details, see https://www.gnu.org/software/gawk/manual/htmlnode/Printf.html.\n"
                },
                {
                    "name": "Special File Names",
                    "content": "When doing I/O redirection from either print or printf into a file, or  via  getline  from  a\nfile,  gawk recognizes certain special filenames internally.  These filenames allow access to\nopen file descriptors inherited from gawk's parent process (usually the shell).   These  file\nnames may also be used on the command line to name data files.  The filenames are:\n\n-           The standard input.\n\n/dev/stdin  The standard input.\n\n/dev/stdout The standard output.\n\n/dev/stderr The standard error output.\n\n/dev/fd/n   The file associated with the open file descriptor n.\n\nThe  following  special  filenames  may  be  used with the |& coprocess operator for creating\nTCP/IP network connections:\n\n/inet/tcp/lport/rhost/rport\n/inet4/tcp/lport/rhost/rport\n/inet6/tcp/lport/rhost/rport\nFiles for a TCP/IP connection on local port lport to remote host rhost on remote  port\nrport.   Use  a port of 0 to have the system pick a port.  Use /inet4 to force an IPv4\nconnection, and /inet6 to force an IPv6 connection.  Plain /inet uses the  system  de‐\nfault (most likely IPv4).  Usable only with the |& two-way I/O operator.\n\n/inet/udp/lport/rhost/rport\n/inet4/udp/lport/rhost/rport\n/inet6/udp/lport/rhost/rport\nSimilar, but use UDP/IP instead of TCP/IP.\n"
                },
                {
                    "name": "Numeric Functions",
                    "content": "AWK has the following built-in arithmetic functions:\n\natan2(y, x)   Return the arctangent of y/x in radians.\n\ncos(expr)     Return the cosine of expr, which is in radians.\n\nexp(expr)     The exponential function.\n\nint(expr)     Truncate to integer.\n\nlog(expr)     The natural logarithm function.\n\nrand()        Return a random number N, between zero and one, such that 0 ≤ N < 1.\n\nsin(expr)     Return the sine of expr, which is in radians.\n\nsqrt(expr)    Return the square root of expr.\n\nsrand([expr]) Use  expr  as the new seed for the random number generator.  If no expr is pro‐\nvided, use the time of day.  Return the previous seed  for  the  random  number\ngenerator.\n"
                },
                {
                    "name": "String Functions",
                    "content": "Gawk   has   the   following   built-in   string   functions;   details   are   provided   in\nhttps://www.gnu.org/software/gawk/manual/htmlnode/String-Functions.\n\nasort(s [, d [, how] ]) Return the number of elements in the source array s.  Sort  the  con‐\ntents  of  s  using gawk's normal rules for comparing values, and re‐\nplace the indices of the sorted values  s  with  sequential  integers\nstarting  with  1.  If the optional destination array d is specified,\nfirst duplicate s into d, and then sort d, leaving the indices of the\nsource array s unchanged. The optional string how controls the direc‐\ntion and the comparison mode.  Valid values for how are described  in\nhttps://www.gnu.org/software/gawk/manual/htmlnode/String-Func‐\ntions.html#String-Functions.   s and d are allowed to be the same ar‐\nray; this only makes sense when supplying the third argument as well.\n\nasorti(s [, d [, how] ])\nReturn the number of elements in the source array s.  The behavior is\nthe same as that of asort(), except that the array indices  are  used\nfor  sorting,  not the array values.  When done, the array is indexed\nnumerically, and the values are those of the original  indices.   The\noriginal  values are lost; thus provide a second array if you wish to\npreserve the original.  The purpose of the optional string how is the\nsame as for asort().  Here too, s and d are allowed to  be  the  same\narray;  this  only  makes  sense when supplying the third argument as\nwell.\n\ngensub(r, s, h [, t])   Search the target string t for matches of the regular  expression  r.\nIf h is a string beginning with g or G, then replace all matches of r\nwith  s.  Otherwise, h is a number indicating which match of r to re‐\nplace.  If t is not supplied, use $0 instead.  Within the replacement\ntext s, the sequence \\n, where n is a digit from 1 to 9, may be  used\nto  indicate just the text that matched the n'th parenthesized subex‐\npression.  The sequence \\0 represents the  entire  matched  text,  as\ndoes  the  character &.  Unlike sub() and gsub(), the modified string\nis returned as the result of the function, and  the  original  target\nstring is not changed.\n\ngsub(r, s [, t])        For each substring matching the regular expression r in the string t,\nsubstitute  the string s, and return the number of substitutions.  If\nt is not supplied, use $0.  An & in the replacement text is  replaced\nwith  the text that was actually matched.  Use \\& to get a literal &.\n(This  must  be  typed  as   \"\\\\&\";   see   https://www.gnu.org/soft‐\nware/gawk/manual/htmlnode/Gory-Details.html#Gory-Details    for    a\nfuller discussion of the rules for ampersands and backslashes in  the\nreplacement text of sub(), gsub(), and gensub().)\n\nindex(s, t)             Return the index of the string t in the string s, or zero if t is not\npresent.  (This implies that character indices start at one.)\n\nlength([s])             Return  the  length  of the string s, or the length of $0 if s is not\nsupplied.  With an array argument, length() returns the number of el‐\nements in the array.\n\nmatch(s, r [, a])       Return the position in s where the regular expression  r  occurs,  or\nzero  if  r is not present, and set the values of RSTART and RLENGTH.\nNote that the argument order is the same as for the ~ operator: str ~\nre.   See  https://www.gnu.org/software/gawk/manual/htmlnode/String-\nFunctions.html#String-Functions  for a description of how the array a\nis filled if it is provided.\n\npatsplit(s, a [, r [, seps] ])\nSplit the string s into the array a and the separators array seps  on\nthe  regular  expression r, and return the number of fields.  Element\nvalues are the portions of s that matched r.  The value of seps[i] is\nthe possibly null separator that appeared after a[i].  The  value  of\nseps[0]  is  the  possibly  null leading separator.  If r is omitted,\nFPAT is used instead.  The arrays  a  and  seps  are  cleared  first.\nSplitting behaves identically to field splitting with FPAT.\n\nsplit(s, a [, r [, seps] ])\nSplit  the string s into the array a and the separators array seps on\nthe regular expression r, and return the number of fields.  If  r  is\nomitted,  FS  is  used  instead.   The  arrays a and seps are cleared\nfirst.  seps[i] is the field separator matched by r between a[i]  and\na[i+1].  Splitting behaves identically to field splitting.\n\nsprintf(fmt, expr-list) Print expr-list according to fmt, and return the resulting string.\n\nstrtonum(str)           Examine  str,  and  return  its  numeric value.  If str begins with a\nleading 0, treat it as an octal number.  If str begins with a leading\n0x or 0X, treat it as a hexadecimal number.  Otherwise, assume it  is\na decimal number.\n\nsub(r, s [, t])         Just like gsub(), but replace only the first matching substring.  Re‐\nturn either zero or one.\n\nsubstr(s, i [, n])      Return the at most n-character substring of s starting at i.  If n is\nomitted, use the rest of s.\n\ntolower(str)            Return a copy of the string str, with all the uppercase characters in\nstr  translated  to their corresponding lowercase counterparts.  Non-\nalphabetic characters are left unchanged.\n\ntoupper(str)            Return a copy of the string str, with all the lowercase characters in\nstr translated to their corresponding uppercase  counterparts.   Non-\nalphabetic characters are left unchanged.\n\nGawk is multibyte aware.  This means that index(), length(), substr() and match() all work in\nterms of characters, not bytes.\n"
                },
                {
                    "name": "Time Functions",
                    "content": "Gawk  provides the following functions for obtaining time stamps and formatting them. Details\nare provided in https://www.gnu.org/software/gawk/manual/htmlnode/Time-Functions.\n\nmktime(datespec [, utc-flag])\nTurn datespec into a time stamp of the same form as returned by systime(), and  re‐\nturn  the  result.  If utc-flag is present and is non-zero or non-null, the time is\nassumed to be in the UTC time zone; otherwise, the time is assumed to be in the lo‐\ncal time zone.  If datespec does not contain enough elements or  if  the  resulting\ntime   is  out  of  range,  mktime()  returns  -1.   See  https://www.gnu.org/soft‐\nware/gawk/manual/htmlnode/Time-Functions.html#Time-Functions for  the  details  of\ndatespec.\n\nstrftime([format [, timestamp[, utc-flag]]])\nFormat  timestamp according to the specification in format.  If utc-flag is present\nand is non-zero or non-null, the result is in UTC, otherwise the result is in local\ntime.  The timestamp should be of the same form as returned by systime().  If time‐\nstamp is missing, the current time of day is used.  If format is missing, a default\nformat equivalent to the output of date(1) is used.  The default format  is  avail‐\nable in PROCINFO[\"strftime\"].  See the specification for the strftime() function in\nISO C for the format conversions that are guaranteed to be available.\n\nsystime() Return the current time of day as the number of seconds since the Epoch (1970-01-01\n00:00:00 UTC on POSIX systems).\n"
                },
                {
                    "name": "Bit Manipulations Functions",
                    "content": "Gawk  supplies the following bit manipulation functions.  They work by converting double-pre‐\ncision floating point values to uintmaxt integers, doing the operation, and then  converting\nthe  result  back  to  floating  point.   Passing negative operands to any of these functions\ncauses a fatal error.\n\nThe functions are:\n\nand(v1, v2 [, ...]) Return the bitwise AND of the  values  provided  in  the  argument  list.\nThere must be at least two.\n\ncompl(val)          Return the bitwise complement of val.\n\nlshift(val, count)  Return the value of val, shifted left by count bits.\n\nor(v1, v2 [, ...])  Return the bitwise OR of the values provided in the argument list.  There\nmust be at least two.\n\nrshift(val, count)  Return the value of val, shifted right by count bits.\n\nxor(v1, v2 [, ...]) Return  the  bitwise  XOR  of  the  values provided in the argument list.\nThere must be at least two.\n"
                },
                {
                    "name": "Type Functions",
                    "content": "The following functions provide type related information about their arguments.\n\nisarray(x) Return true if x is an array, false otherwise.\n\ntypeof(x)  Return a string indicating the type of x.  The string  will  be  one  of  \"array\",\n\"number\", \"regexp\", \"string\", \"strnum\", \"unassigned\", or \"undefined\".\n"
                },
                {
                    "name": "Internationalization Functions",
                    "content": "The  following  functions may be used from within your AWK program for translating strings at\nrun-time.  For  full  details,  see  https://www.gnu.org/software/gawk/manual/htmlnode/I18N-\nFunctions.html#I18N-Functions.\n\nbindtextdomain(directory [, domain])\nSpecify  the  directory  where gawk looks for the .gmo files, in case they will not or\ncannot be placed in the ``standard'' locations.  It returns the directory where domain\nis ``bound.''\nThe default domain is the value of TEXTDOMAIN.  If directory is the null string  (\"\"),\nthen bindtextdomain() returns the current binding for the given domain.\n\ndcgettext(string [, domain [, category]])\nReturn  the  translation of string in text domain domain for locale category category.\nThe default value for domain is the current value of TEXTDOMAIN.   The  default  value\nfor category is \"LCMESSAGES\".\n\ndcngettext(string1, string2, number [, domain [, category]])\nReturn  the  plural  form used for number of the translation of string1 and string2 in\ntext domain domain for locale category category.  The default value for domain is  the\ncurrent value of TEXTDOMAIN.  The default value for category is \"LCMESSAGES\".\n"
                },
                {
                    "name": "Boolean Valued Functions",
                    "content": "You  can  create  special Boolean-typed values; see the manual for how they work and why they\nexist.\n\nmkbool(expression)\nBased on the boolean value of expression return either a true value or a false  value.\nTrue values have numeric value one.  False values have numeric value zero.\n"
                }
            ]
        },
        "USER-DEFINED FUNCTIONS": {
            "content": "Functions in AWK are defined as follows:\n\nfunction name(parameter list) { statements }\n\nFunctions execute when they are called from within expressions in either patterns or actions.\nActual parameters supplied in the function call are used to instantiate the formal parameters\ndeclared  in  the  function.   Arrays  are passed by reference, other variables are passed by\nvalue.\n\nLocal variables are declared as extra parameters in the parameter list.  The convention is to\nseparate local variables from real parameters by extra spaces in the parameter list.  For ex‐\nample:\n\nfunction  f(p, q,     a, b)   # a and b are local\n{\n...\n}\n\n/abc/     { ... ; f(1, 2) ; ... }\n\nThe left parenthesis in a function call is required to immediately follow the function  name,\nwithout  any  intervening  whitespace.  This restriction does not apply to the built-in func‐\ntions listed above.\n\nFunctions may call each other and may be recursive.  Function parameters used as local  vari‐\nables are initialized to the null string and the number zero upon function invocation.\n\nUse return expr to return a value from a function.  The return value is undefined if no value\nis provided, or if the function returns by “falling off” the end.\n\nFunctions may be called indirectly. To do this, assign the name of the function to be called,\nas a string, to a variable.  Then use the variable as if it were the name of a function, pre‐\nfixed with an @ sign, like so:\nfunction myfunc()\n{\nprint \"myfunc called\"\n...\n}\n\n{    ...\nthefunc = \"myfunc\"\n@thefunc()    # call through thefunc to myfunc\n...\n}\n\nIf --lint has been provided, gawk warns about calls to undefined functions at parse time, in‐\nstead of at run time.  Calling an undefined function at run time is a fatal error.\n",
            "subsections": []
        },
        "DYNAMICALLY LOADING NEW FUNCTIONS": {
            "content": "You  can  dynamically  add  new functions written in C or C++ to the running gawk interpreter\nwith the @load statement.  The full details are beyond the scope of  this  manual  page;  see\nhttps://www.gnu.org/software/gawk/manual/htmlnode/Dynamic-Extensions.html#Dynamic-Exten‐\nsions.\n",
            "subsections": []
        },
        "SIGNALS": {
            "content": "The gawk profiler accepts two signals.  SIGUSR1 causes it to dump a profile and function call\nstack  to  the profile file, which is either awkprof.out, or whatever file was named with the\n--profile option.  It then continues to run.  SIGHUP causes gawk  to  dump  the  profile  and\nfunction call stack and then exit.\n",
            "subsections": []
        },
        "INTERNATIONALIZATION": {
            "content": "String  constants  are  sequences  of  characters  enclosed in double quotes.  In non-English\nspeaking environments, it is possible to mark strings in the AWK program as requiring  trans‐\nlation to the local natural language. Such strings are marked in the AWK program with a lead‐\ning underscore (“”).  For example,\n\ngawk 'BEGIN { print \"hello, world\" }'\n\nalways prints hello, world.  But,\n\ngawk 'BEGIN { print \"hello, world\" }'\n\nmight   print   bonjour,   monde   in   France.   See  https://www.gnu.org/software/gawk/man‐\nual/htmlnode/Internationalization.html#Internationalization for the steps involved  in  pro‐\nducing and running a localizable AWK program.\n",
            "subsections": []
        },
        "GNU EXTENSIONS": {
            "content": "Gawk   has   a  too-large  number  of  extensions  to  POSIX  awk.   They  are  described  in\nhttps://www.gnu.org/software/gawk/manual/htmlnode/POSIX002fGNU.html.   All  the  extensions\ncan be disabled by invoking gawk with the --traditional or --posix options.\n",
            "subsections": []
        },
        "ENVIRONMENT VARIABLES": {
            "content": "The  AWKPATH  environment  variable  can  be  used to provide a list of directories that gawk\nsearches when looking for files named via the -f, --file, -i and --include options,  and  the\n@include  directive.  If the initial search fails, the path is searched again after appending\n.awk to the filename.\n\nThe AWKLIBPATH environment variable can be used to provide a list of  directories  that  gawk\nsearches when looking for files named via the -l and --load options.\n\nThe  GAWKPERSISTFILE environment variable, if present, specifies a file to use as the back‐\ning store for persistent memory.  This is an experimental feature.  See GAWK:  Effective  AWK\nProgramming for the details.\n\nThe  GAWKREADTIMEOUT  environment variable can be used to specify a timeout in milliseconds\nfor reading input from a terminal, pipe or two-way communication including sockets.\n\nFor connection to a remote host via socket, GAWKSOCKRETRIES controls the number of retries,\nand GAWKMSECSLEEP the interval between retries.  The interval is in milliseconds.  On  sys‐\ntems that do not support usleep(3), the value is rounded up to an integral number of seconds.\n\nIf  POSIXLYCORRECT  exists  in  the environment, then gawk behaves exactly as if --posix had\nbeen specified on the command line.  If --lint has been specified, gawk issues a warning mes‐\nsage to this effect.\n",
            "subsections": []
        },
        "EXIT STATUS": {
            "content": "If the exit statement is used with a value, then gawk exits with the numeric value  given  to\nit.\n\nOtherwise,  if  there  were  no problems during execution, gawk exits with the value of the C\nconstant EXITSUCCESS.  This is usually zero.\n\nIf an error occurs, gawk exits with the value of the C constant EXITFAILURE.  This  is  usu‐\nally one.\n\nIf  gawk  exits  because  of a fatal error, the exit status is 2.  On non-POSIX systems, this\nvalue may be mapped to EXITFAILURE.\n",
            "subsections": []
        },
        "VERSION INFORMATION": {
            "content": "This man page documents gawk, version 5.2.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "The original version of UNIX awk was designed and implemented  by  Alfred  Aho,  Peter  Wein‐\nberger,  and Brian Kernighan of Bell Laboratories.  Brian Kernighan continues to maintain and\nenhance it.\n\nPaul Rubin and Jay Fenlason, of the Free Software Foundation, wrote gawk,  to  be  compatible\nwith the original version of awk distributed in Seventh Edition UNIX.  John Woods contributed\na number of bug fixes.  David Trueman, with contributions from Arnold Robbins, made gawk com‐\npatible with the new version of UNIX awk.  Arnold Robbins is the current maintainer.\n\nSee GAWK: Effective AWK Programming for a full list of the contributors to gawk and its docu‐\nmentation.\n\nSee the README file in the gawk distribution for up-to-date information about maintainers and\nwhich ports are currently supported.\n",
            "subsections": []
        },
        "BUG REPORTS": {
            "content": "If you find a bug in gawk, please use the gawkbug(1) program to report it.\n\nFull  instructions for reporting a bug are provided in https://www.gnu.org/software/gawk/man‐\nual/htmlnode/Bugs.html.  Please carefully read and  follow  the  instructions  given  there.\nThis will make bug reporting and resolution much easier for everyone involved.  Really.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "The -F option is not necessary given the command line variable assignment feature; it remains\nonly for backwards compatibility.\n\nThis manual page is too long; gawk has too many features.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "egrep(1), sed(1), gawkbug(1), printf(3), and strftime(3).\n\nThe  AWK  Programming Language, Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger, Addi‐\nson-Wesley, 1988.  ISBN 0-201-07981-X.\n\nGAWK: Effective AWK Programming, Edition 5.2, shipped with the gawk source.  The current ver‐\nsion of this document is available online at https://www.gnu.org/software/gawk/manual.\n\nThe GNU gettext documentation, available online at https://www.gnu.org/software/gettext.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "Print and sort the login names of all users:\n\nBEGIN     { FS = \":\" }\n{ print $1 | \"sort\" }\n\nCount lines in a file:\n\n{ nlines++ }\nEND  { print nlines }\n\nPrecede each line by its number in the file:\n\n{ print FNR, $0 }\n\nConcatenate and line number (a variation on a theme):\n\n{ print NR, $0 }\n\nRun an external command for particular lines of data:\n\ntail -f accesslog |\nawk '/myhome.html/ { system(\"nmap \" $1 \">> logdir/myhome.html\") }'\n",
            "subsections": []
        },
        "COPYING PERMISSIONS": {
            "content": "Copyright © 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,  1999,  2001,  2002,  2003,\n2004,  2005,  2007,  2009,  2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020,\n2021, 2022 Free Software Foundation, Inc.\n\nPermission is granted to make and distribute verbatim copies of this manual page provided the\ncopyright notice and this permission notice are preserved on all copies.\n\nPermission is granted to copy and distribute modified versions of this manual page under  the\nconditions  for verbatim copying, provided that the entire resulting derived work is distrib‐\nuted under the terms of a permission notice identical to this one.\n\nPermission is granted to copy and distribute translations of this manual  page  into  another\nlanguage,  under  the above conditions for modified versions, except that this permission no‐\ntice may be stated in a translation approved by the Foundation.\n\nFree Software Foundation                     Jun 09 2022                                     GAWK(1)",
            "subsections": []
        }
    },
    "summary": "gawk - pattern scanning and processing language",
    "flags": [
        {
            "flag": "-f",
            "long": "--file",
            "arg": null,
            "description": "Read the AWK program source from the file program-file, instead of from the first com‐ mand line argument. Multiple -f options may be used. Files read with -f are treated as if they begin with an implicit @namespace \"awk\" statement."
        },
        {
            "flag": "-F",
            "long": "--field-separator",
            "arg": null,
            "description": "Use fs for the input field separator (the value of the FS predefined variable)."
        },
        {
            "flag": "-v",
            "long": "--assign",
            "arg": null,
            "description": "Assign the value val to the variable var, before execution of the program begins. Such variable values are available to the BEGIN rule of an AWK program."
        },
        {
            "flag": "-b",
            "long": "--characters-as-bytes",
            "arg": null,
            "description": "Treat all input data as single-byte characters. The --posix option overrides this one."
        },
        {
            "flag": "-c",
            "long": "--traditional",
            "arg": null,
            "description": "Run in compatibility mode. In compatibility mode, gawk behaves identically to Brian Kernighan's awk; none of the GNU-specific extensions are recognized."
        },
        {
            "flag": "-C",
            "long": "--copyright",
            "arg": null,
            "description": "Print the short version of the GNU copyright information message on the standard out‐ put and exit successfully."
        },
        {
            "flag": "-d",
            "long": "--dump-variables",
            "arg": null,
            "description": "Print a sorted list of global variables, their types and final values to file. The default file is awkvars.out in the current directory."
        },
        {
            "flag": "-D",
            "long": "--debug",
            "arg": null,
            "description": "Enable debugging of AWK programs. By default, the debugger reads commands interac‐ tively from the keyboard (standard input). The optional file argument specifies a file with a list of commands for the debugger to execute non-interactively. In this mode of execution, gawk loads the AWK source code and then prompts for debug‐ ging commands. Gawk can only debug AWK program source provided with the -f and --in‐ clude options. The debugger is documented in GAWK: Effective AWK Programming; see https://www.gnu.org/software/gawk/manual/htmlnode/Debugger.html#Debugger."
        },
        {
            "flag": "-e",
            "long": "--source",
            "arg": null,
            "description": "Use program-text as AWK program source code. Each argument supplied via -e is treated as if it begins with an implicit @namespace \"awk\" statement."
        },
        {
            "flag": "-E",
            "long": "--exec",
            "arg": null,
            "description": "Similar to -f, however, this is option is the last one processed. This should be used with #! scripts, particularly for CGI applications, to avoid passing in options or source code (!) on the command line from a URL. This option disables command-line variable assignments."
        },
        {
            "flag": "-g",
            "long": "--gen-pot",
            "arg": null,
            "description": "Scan and parse the AWK program, and generate a GNU .pot (Portable Object Template) format file on standard output with entries for all localizable strings in the pro‐ gram. The program itself is not executed."
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "Print a relatively short summary of the available options on the standard output. Per the GNU Coding Standards, these options cause an immediate, successful exit."
        },
        {
            "flag": "-i",
            "long": "--include",
            "arg": null,
            "description": "Load an awk source library. This searches for the library using the AWKPATH environ‐ ment variable. If the initial search fails, another attempt will be made after ap‐ pending the .awk suffix. The file will be loaded only once (i.e., duplicates are eliminated), and the code does not constitute the main program source. Files read with --include are treated as if they begin with an implicit @namespace \"awk\" state‐ ment."
        },
        {
            "flag": "-I",
            "long": "--trace",
            "arg": null,
            "description": "Print the internal byte code names as they are executed when running the program. The trace is printed to standard error. Each ``op code'' is preceded by a + sign in the output."
        },
        {
            "flag": "-l",
            "long": "--load",
            "arg": null,
            "description": "Load a gawk extension from the shared library lib. This searches for the library us‐ ing the AWKLIBPATH environment variable. If the initial search fails, another attempt will be made after appending the default shared library suffix for the platform. The library initialization routine is expected to be named dlload()."
        },
        {
            "flag": "-L",
            "long": "--lint",
            "arg": null,
            "description": "Provide warnings about constructs that are dubious or non-portable to other AWK imple‐ mentations. See https://www.gnu.org/software/gawk/manual/htmlnode/Options.html#Op‐ tions for the list of possible values for value."
        },
        {
            "flag": "-M",
            "long": "--bignum",
            "arg": null,
            "description": "Force arbitrary precision arithmetic on numbers. This option has no effect if gawk is not compiled to use the GNU MPFR and GMP libraries. (In such a case, gawk issues a warning.) NOTE: This feature is on parole. The primary gawk maintainer is no longer supporting it, although there is a member of the development team who is. If this situation changes, the feature will be removed from gawk."
        },
        {
            "flag": "-n",
            "long": "--non-decimal-data",
            "arg": null,
            "description": "Recognize octal and hexadecimal values in input data. Use this option with great cau‐ tion!"
        },
        {
            "flag": "-N",
            "long": "--use-lc-numeric",
            "arg": null,
            "description": "Force gawk to use the locale's decimal point character when parsing input data."
        },
        {
            "flag": "-o",
            "long": "--pretty-print",
            "arg": null,
            "description": "Output a pretty printed version of the program to file. The default file is awkprof.out in the current directory. This option implies --no-optimize."
        },
        {
            "flag": "-O",
            "long": "--optimize",
            "arg": null,
            "description": "Enable gawk's default optimizations upon the internal representation of the program. This option is on by default."
        },
        {
            "flag": "-p",
            "long": "--profile",
            "arg": null,
            "description": "Start a profiling session, and send the profiling data to prof-file. The default is awkprof.out in the current directory. The profile contains execution counts of each statement in the program in the left margin and function call counts for each user-de‐ fined function. Gawk runs more slowly in this mode. This option implies --no-opti‐ mize."
        },
        {
            "flag": "-P",
            "long": "--posix",
            "arg": null,
            "description": "This turns on compatibility mode, and disables a number of common extensions."
        },
        {
            "flag": "-r",
            "long": "--re-interval",
            "arg": null,
            "description": "Enable the use of interval expressions in regular expression matching. Interval ex‐ pressions are enabled by default, but this option remains for backwards compatibility."
        },
        {
            "flag": "-s",
            "long": "--no-optimize",
            "arg": null,
            "description": "Disable gawk's default optimizations upon the internal representation of the program."
        },
        {
            "flag": "-S",
            "long": "--sandbox",
            "arg": null,
            "description": "Run gawk in sandbox mode, disabling the system() function, input redirection with get‐ line, output redirection with print and printf, and loading dynamic extensions. Com‐ mand execution (through pipelines) is also disabled."
        },
        {
            "flag": "-t",
            "long": "--lint-old",
            "arg": null,
            "description": "Provide warnings about constructs that are not portable to the original version of UNIX awk."
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "Print version information for this particular copy of gawk on the standard output. This is useful when reporting bugs. Per the GNU Coding Standards, these options cause an immediate, successful exit. -- Signal the end of options. This is useful to allow further arguments to the AWK pro‐ gram itself to start with a “-”. In compatibility mode, any other options are flagged as invalid, but are otherwise ignored. In normal operation, as long as program text has been supplied, unknown options are passed on to the AWK program in the ARGV array for processing. For POSIX compatibility, the -W option may be used, followed by the name of a long option."
        }
    ],
    "examples": [
        "Print and sort the login names of all users:",
        "BEGIN     { FS = \":\" }",
        "{ print $1 | \"sort\" }",
        "Count lines in a file:",
        "{ nlines++ }",
        "END  { print nlines }",
        "Precede each line by its number in the file:",
        "{ print FNR, $0 }",
        "Concatenate and line number (a variation on a theme):",
        "{ print NR, $0 }",
        "Run an external command for particular lines of data:",
        "tail -f accesslog |",
        "awk '/myhome.html/ { system(\"nmap \" $1 \">> logdir/myhome.html\") }'"
    ],
    "see_also": [
        {
            "name": "egrep",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/egrep/1/json"
        },
        {
            "name": "sed",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/sed/1/json"
        },
        {
            "name": "gawkbug",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/gawkbug/1/json"
        },
        {
            "name": "printf",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/printf/3/json"
        },
        {
            "name": "strftime",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/strftime/3/json"
        }
    ]
}