{"id":3486,"date":"2014-08-23T14:36:53","date_gmt":"2014-08-23T06:36:53","guid":{"rendered":"http:\/\/rmohan.com\/?p=3486"},"modified":"2014-08-23T18:40:54","modified_gmt":"2014-08-23T10:40:54","slug":"awk-cheat","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=3486","title":{"rendered":"awk.cheat"},"content":{"rendered":"<pre style=\"color: #000000;\">.-----------------------------------------------------------------------.\r\n|                                                                       |\r\n|                              AWK Cheat Sheet                          |\r\n|                                                                       |\r\n'-----------------------------------------------------------------------'\r\n| Peteris Krumins (peter@catonmat.net), 2007.08.22                      |\r\n| http:\/\/www.catonmat.net  -  good coders code, great reuse             |\r\n'-----------------------------------------------------------------------'\r\n\r\n\r\n ===================== Predefined Variable Summary =====================\r\n\r\n.-------------+-----------------------------------.---------------------.\r\n|             |                                   |      Support:       |\r\n| Variable    | Description                       '-----.-------.-------'\r\n|             |                                   | AWK | NAWK  | GAWK  |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| FS          | Input Field Separator, a space by |  +  |   +   |   +   |\r\n|             | default.                          |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| OFS         | Output Field Separator, a space   |  +  |   +   |   +   |\r\n|             | by default.                       |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| NF          | The Number of Fields in the       |  +  |   +   |   +   |\r\n|             | current input record.             |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| NR          | The total Number of input Records |  +  |   +   |   +   |\r\n|             | seen so far.                      |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| RS          | Record Separator, a newline by    |  +  |   +   |   +   |\r\n|             | default.                          |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| ORS         | Output Record Separator, a        |  +  |   +   |   +   |\r\n|             | newline by default.               |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| FILENAME    | The name of the current input     |     |       |       |\r\n|             | file. If no files are specified   |     |       |       |\r\n|             | on the command line, the value of |     |       |       |\r\n|             | FILENAME is \"-\". However,         |  +  |   +   |   +   |\r\n|             | FILENAME is undefined inside the  |     |       |       |\r\n|             | BEGIN block (unless set by        |     |       |       |\r\n|             | getline).                         |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| ARGC        | The number of command line        |     |       |       |\r\n|             | arguments (does not include       |     |       |       |\r\n|             | options to gawk, or the program   |  -  |   +   |   +   |\r\n|             | source). Dynamically changing the |     |       |       |\r\n|             | contents of ARGV control the      |  -  |   +   |   +   |\r\n|             | files used for data.              |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| ARGV        | Array of command line arguments.  |     |       |       |\r\n|             | The array is indexed from 0 to    |  -  |   +   |   +   |\r\n|             | ARGC - 1.                         |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| ARGIND      | The index in ARGV of the current  |  -  |   -   |   +   |\r\n|             | file being processed.             |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| BINMODE     | On non-POSIX systems, specifies   |     |       |       |\r\n|             | use of \"binary\" mode for all file |     |       |       |\r\n|             | I\/O.Numeric values of 1, 2, or 3, |     |       |       |\r\n|             | specify that input files, output  |     |       |       |\r\n|             | files, or all files, respectively,|     |       |       |\r\n|             | should use binary I\/O. String     |     |       |       |\r\n|             | values of  \"r\", or \"w\" specify    |  -  |   -   |   +   |\r\n|             | that input files, or output files,|     |       |       |\r\n|             | respectively, should use binary   |     |       |       |\r\n|             | I\/O. String values of \"rw\" or     |     |       |       |\r\n|             |  \"wr\" specify that all files      |     |       |       |\r\n|             | should use binary I\/O. Any other  |     |       |       |\r\n|             | string value is treated as \"rw\",  |     |       |       |\r\n|             | but generates a warning message.  |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| CONVFMT     | The CONVFMT variable is used to   |     |       |       |\r\n|             | specify the format when           |  -  |   -   |   +   |\r\n|             | converting a number to a string.  |     |       |       |\r\n|             | Default: \"%.6g\"                   |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| ENVIRON     | An array containing the values    |  -  |   -   |   +   |\r\n|             | of the current environment.       |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| ERRNO       | If a system error occurs either   |     |       |       |\r\n|             | doing a redirection for getline,  |     |       |       |\r\n|             | during a read for getline, or     |     |       |       |\r\n|             | during a close(), then ERRNO will |  -  |   -   |   +   |\r\n|             | contain a string describing the   |     |       |       |\r\n|             | error. The value is subject to    |     |       |       |\r\n|             | translation in non-English locales.     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| FIELDWIDTHS | A white-space separated list of   |     |       |       |\r\n|             | fieldwidths. When set, gawk       |     |       |       |\r\n|             | parses the input into fields of   |  -  |   -   |   +   |\r\n|             | fixed width, instead of using the |     |       |       |\r\n|             | value of the FS variable as the   |     |       |       |\r\n|             | field separator.                  |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| FNR         | Contains number of lines read,    |  -  |   +   |   +   |\r\n|             | but is reset for each file read.  |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| IGNORECASE  | Controls the case-sensitivity of  |     |       |       |\r\n|             | all regular expression and string |     |       |       |\r\n|             | operations. If IGNORECASE has a   |     |       |       |\r\n|             | non-zero value, then string       |     |       |       |\r\n|             | comparisons and pattern matching  |     |       |       |\r\n|             | in rules, field splitting         |     |       |       |\r\n|             | with FS, record separating        |     |       |       |\r\n|             | with RS, regular expression       |     |       |       |\r\n|             | matching with ~ and !~, and the   |  -  |   -   |   +   |\r\n|             | gensub(), gsub(), index(),        |     |       |       |\r\n|             | match(), split(), and sub()       |     |       |       |\r\n|             | built-in functions all ignore     |     |       |       |\r\n|             | case when doing regular           |     |       |       |\r\n|             | expression operations.            |     |       |       |\r\n|             | NOTE: Array subscripting is not   |     |       |       |\r\n|             | affected. However, the asort()    |     |       |       |\r\n|             | and asorti() functions are        |     |       |       |\r\n|             | affected                          |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| LINT        | Provides dynamic control of the   |     |       |       |\r\n|             | --lint option from within an AWK  |  -  |   -   |   +   |\r\n|             | program. When true, gawk prints   |     |       |       |\r\n|             | lint warnings.                    |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| OFMT        | The default output format for     |  -  |   +   |   +   |\r\n|             | numbers. Default: \"%.6g\"          |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| PROCINFO    | The elements of this array        |     |       |       |\r\n|             | provide access to information     |     |       |       |\r\n|             | about the running AWK program.    |     |       |       |\r\n|             | PROCINFO[\"egid\"]:                 |     |       |       |\r\n|             | the value of the getegid(2)       |     |       |       |\r\n|             | system call.                      |     |       |       |\r\n|             | PROCINFO[\"euid\"]:                 |     |       |       |\r\n|             | the value of the geteuid(2)       |     |       |       |\r\n|             | system call.                      |     |       |       |\r\n|             | PROCINFO[\"FS\"]:                   |     |       |       |\r\n|             | \"FS\" if field splitting with FS   |     |       |       |\r\n|             | is in effect, or \"FIELDWIDTHS\"    |     |       |       |\r\n|             | if field splitting with           |     |       |       |\r\n|             | FIELDWIDTHS is in effect.         |     |       |       |\r\n|             | PROCINFO[\"gid\"]:                  |  -  |   -   |   +   |\r\n|             | the value of the getgid(2) system |     |       |       |\r\n|             | call.                             |     |       |       |\r\n|             | PROCINFO[\"pgrpid\"]:               |     |       |       |\r\n|             | the process group ID of the       |     |       |       |\r\n|             | current process.                  |     |       |       |\r\n|             | PROCINFO[\"pid\"]:                  |     |       |       |\r\n|             | the process ID of the current     |     |       |       |\r\n|             | process.                          |     |       |       |\r\n|             | PROCINFO[\"ppid\"]:                 |     |       |       |\r\n|             | the parent process ID of the      |     |       |       |\r\n|             | current process.                  |     |       |       |\r\n|             | PROCINFO[\"uid\"]                   |     |       |       |\r\n|             | the value of the getuid(2) system |     |       |       |\r\n|             | call.                             |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| RT          | The record terminator. Gawk sets  |     |       |       |\r\n|             | RT to the input text that matched |  -  |   -   |   +   |\r\n|             | the character or regular          |     |       |       |\r\n|             | expression specified by RS.       |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| RSTART      | The index of the first character  |  -  |   +   |   +   |\r\n|             | matched by match(); 0 if no match.|     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| RLENGTH     | The length of the string matched  |  -  |   +   |   +   |\r\n|             | by match(); -1 if no match.       |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| SUBSEP      | The character used to separate    |     |       |       |\r\n|             | multiple subscripts in array      |     |       |       |\r\n|             | elements.Default: \"\\034\"          |  -  |   +   |   +   |\r\n|             | (non-printable character,         |     |       |       |\r\n|             | dec: 28, hex: 1C)                 |     |       |       |\r\n'-------------+-----------------------------------+-----+-------+-------'\r\n| TEXTDOMAIN  | The text domain of the AWK        |     |       |       |\r\n|             | program; used to find the         |  -  |   -   |   +   |\r\n|             | localized translations for the    |     |       |       |\r\n|             | program's strings.                |     |       |       |\r\n'-------------'-----------------------------------'-----'-------'-------'\r\n\r\n\r\n ============================ I\/O Statements ===========================\r\n\r\n.---------------------.-------------------------------------------------.\r\n|                     |                                                 |\r\n| Statement           | Description                                     |\r\n|                     |                                                 |\r\n'---------------------+-------------------------------------------------'\r\n| close(file [, how]) | Close file, pipe or co-process. The optional    |\r\n|                     | how should only be used when closing one end of |\r\n|                     | a two-way pipe to a co-process. It must be a    |\r\n|                     | string value, either \"to\" or \"from\".            |\r\n'---------------------+-------------------------------------------------'\r\n| getline             | Set $0 from next input record; set NF, NR, FNR. |\r\n|                     | Returns 0 on EOF and ?1 on an error. Upon an    |\r\n|                     | error, ERRNO contains a string describing the   |\r\n|                     | problem.                                        |\r\n'---------------------+-------------------------------------------------'\r\n| getline &lt;file       | Set $0 from next record of file; set NF.        |\r\n'---------------------+-------------------------------------------------'\r\n| getline var         | Set var from next input record; set NR, FNR.    |\r\n'---------------------+-------------------------------------------------'\r\n| getline var &lt;file   | Set var from next record of file.               |\r\n'---------------------+-------------------------------------------------'\r\n| command |           | Run command piping the output either into $0 or |\r\n|   getline [var]     | var, as above. If using a pipe or co-process    |\r\n|                     | to getline, or from print or printf within a    |\r\n|                     | loop, you must use close() to create new        |\r\n|                     | instances                                       |\r\n'---------------------+-------------------------------------------------'\r\n| command |&amp;          | Run command as a co-process piping the output   |\r\n|   getline [var]     | either into $0 or var, as above.  Co-processes  |\r\n|                     | are a gawk extension.                           |\r\n'---------------------+-------------------------------------------------'\r\n| next                | Stop processing the current input record.       |\r\n|                     | The next input record is read and processing    |\r\n|                     | starts over with the first pattern in the AWK   |\r\n|                     | program. If the end of the input data is        |\r\n|                     | reached, the END block(s), if any, are executed.|\r\n'---------------------+-------------------------------------------------'\r\n| nextfile            | Stop processing the current input file. The     |\r\n|                     | next input record read comes from the next      |\r\n|                     | input file. FILENAME and ARGIND are updated,    |\r\n|                     | FNR is reset to 1, and processing starts over   |\r\n|                     | with the first pattern in the AWK program. If   |\r\n|                     | the end of the input data is reached, the END   |\r\n|                     | block(s), are executed.                         |\r\n'---------------------+-------------------------------------------------'\r\n| print               | Prints the current record. The output record is |\r\n|                     | terminated with the value of the ORS variable.  |\r\n'---------------------+-------------------------------------------------'\r\n| print expr-list     | Prints expressions. Each expression is          |\r\n|                     | separated by the value of the OFS variable.     |\r\n|                     | The output record is terminated with the value  |\r\n|                     | of the ORS variable.                            |\r\n'---------------------+-------------------------------------------------'\r\n| print expr-list     | Prints expressions on file. Each expression is  |\r\n|   &gt;file             | separated by the value of the OFS variable. The |\r\n|                     | output record is terminated with the value of   |\r\n|                     | the ORS variable.                               |\r\n'---------------------+-------------------------------------------------'\r\n| printf fmt,         | Format and print.                               |\r\n|   expr-list         |                                                 |\r\n'---------------------+-------------------------------------------------'\r\n| printf fmt,         | Format and print on file.                       |\r\n|   expr-list &gt;file   |                                                 |\r\n'---------------------+-------------------------------------------------'\r\n| system(cmd-line)    | Execute the command cmd-line, and return the    |\r\n|                     | exit status.                                    |\r\n'---------------------+-------------------------------------------------'\r\n| fflush([file])      | Flush any buffers associated with the open      |\r\n|                     | output file or pipe file. If file is missing,   |\r\n|                     | then stdout is flushed. If file is the null     |\r\n|                     | string, then all open output files and pipes    |\r\n|                     | have their buffers flushed.                     |\r\n'---------------------+-------------------------------------------------'\r\n| print ... &gt;&gt; file   | Appends output to the file.                     |\r\n'---------------------+-------------------------------------------------'\r\n| print ... | command | Writes on a pipe.                               |\r\n'---------------------+-------------------------------------------------'\r\n| print ... |&amp;        | Sends data to a co-process.                     |\r\n|   command           |                                                 |\r\n'---------------------'-------------------------------------------------'\r\n\r\n\r\n =========================== Numeric Functions =========================\r\n\r\n.---------------------.-------------------------------------------------.\r\n|                     |                                                 |\r\n| Function            | Description                                     |\r\n|                     |                                                 |\r\n'---------------------+-------------------------------------------------'\r\n| atan2(y, x)         | Returns the arctangent of y\/x in radians.       |\r\n'---------------------+-------------------------------------------------'\r\n| cos(expr)           | Returns the cosine of expr, which is in radians.|\r\n'---------------------+-------------------------------------------------'\r\n| exp(expr)           | The exponential function.                       |\r\n'---------------------+-------------------------------------------------'\r\n| int(expr)           | Truncates to integer.                           |\r\n'---------------------+-------------------------------------------------'\r\n| log(expr)           | The natural logarithm function.                 |\r\n'---------------------+-------------------------------------------------'\r\n| rand()              | Returns a random number N, between 0 and 1,     |\r\n|                     | such that 0 &lt;= N &lt; 1.                           |\r\n'---------------------+-------------------------------------------------'\r\n| sin(expr)           | Returns the sine of expr, which is in radians.  |\r\n'---------------------+-------------------------------------------------'\r\n| sqrt(expr)          | The square root function.                       |\r\n'---------------------+-------------------------------------------------'\r\n| srand([expr])       | Uses expr as a new seed for the random number   |\r\n|                     | generator. If no expr is provided, the time of  |\r\n|                     | day is used. The return value is the previous   |\r\n|                     | seed for the random number generator.           |\r\n'---------------------'-------------------------------------------------'\r\n\r\n\r\n ====================== Bit Manipulation Functions =====================\r\n\r\n.---------------------.-------------------------------------------------.\r\n|                     |                                                 |\r\n| Function            | Description                                     |\r\n|                     |                                                 |\r\n'---------------------+-------------------------------------------------'\r\n| and(v1, v2)         | Return the bitwise AND of the values provided   |\r\n|                     | by v1 and v2.                                   |\r\n'---------------------+-------------------------------------------------'\r\n| compl(val)          | Return the bitwise complement of val.           |\r\n'---------------------+-------------------------------------------------'\r\n| lshift(val, count)  | Return the value of val, shifted left by        |\r\n|                     | count bits.                                     |\r\n'---------------------+-------------------------------------------------'\r\n| or(v1, v2)          | Return the bitwise OR of the values provided by |\r\n|                     | v1 and v2.                                      |\r\n'---------------------+-------------------------------------------------'\r\n| rshift(val, count)  | Return the value of val, shifted right by       |\r\n|                     | count bits.                                     |\r\n'---------------------+-------------------------------------------------'\r\n| xor(v1, v2)         | Return the bitwise XOR of the values provided   |\r\n|                     | by v1 and v2.                                   |\r\n'---------------------'-------------------------------------------------'\r\n\r\n\r\n =========================== String Functions ==========================\r\n\r\n.---------------------.-------------------------------------------------.\r\n|                     |                                                 |\r\n| Function            | Description                                     |\r\n|                     |                                                 |\r\n'---------------------+-------------------------------------------------'\r\n| asort(s [, d])      | Returns the number of elements in the source    |\r\n|                     | array s.  The contents of s are sorted using    |\r\n|                     | gawk's normal rules for comparing values, and   |\r\n|                     | the indexes of the sorted values of s are       |\r\n|                     | replaced with sequential integers starting with |\r\n|                     | 1. If the optional destination array d is       |\r\n|                     | specified, then s is first duplicated into d,   |\r\n|                     | and then d is sorted, leaving the indexes of    |\r\n|                     | the source array s unchanged.                   |\r\n'---------------------+-------------------------------------------------'\r\n| asorti(s [, d])     | Returns the number of elements in the source    |\r\n|                     | array s. The behavior is the same as that of    |\r\n|                     | asort(),  except that the array indices are     |\r\n|                     | used for sorting, not the array values. When    |\r\n|                     | done, the array is indexed numerically, and the |\r\n|                     | values are those of the original indices. The   |\r\n|                     | original values are lost; thus provide a second |\r\n|                     | array if you wish to preserve the original.     |\r\n'---------------------+-------------------------------------------------'\r\n| gensub(r, s,        | Search the target string t for matches of the   |\r\n|   h [, t])          | regular expression r.  If h is a string         |\r\n|                     | beginning with g or G, then replace all matches |\r\n|                     | of r with s. Otherwise, h is a number           |\r\n|                     | indicating which match of r to replace. If t is |\r\n|                     | not supplied, $0 is used instead. Within the    |\r\n|                     | replacement text s, the sequence \\n, where n is |\r\n|                     | a digit from 1 to 9, may be used to indicate    |\r\n|                     | just the text that matched the n'th             |\r\n|                     | parenthesized subexpression. The sequence \\0    |\r\n|                     | represents the entire matched text, as does the |\r\n|                     | character &amp;. Unlike sub() and gsub(), the       |\r\n|                     | modified string is returned as the result of    |\r\n|                     | the function, and the original target string    |\r\n|                     | is not changed.                                 |\r\n'---------------------+-------------------------------------------------'\r\n| gsub(r, s [, t])    | For each substring matching the regular         |\r\n|                     | expression r in the string t, substitute the    |\r\n|                     | string s, and return the number of              |\r\n|                     | substitutions.  If t is not supplied, use $0.   |\r\n|                     | An &amp; in the replacement text is replaced with   |\r\n|                     | the text that was actually matched. Use \\&amp; to   |\r\n|                     | get a literal &amp;.  (This must be                 |\r\n|                     | typed as  \"\\\\&amp;\")                                |\r\n'---------------------+-------------------------------------------------'\r\n| index(s, t)         | Returns the index of the string t in the        |\r\n|                     | string s, or 0 if t is not present. (This       |\r\n|                     | implies that characterindices start at one.)    |\r\n'---------------------+-------------------------------------------------'\r\n| length([s])         | Returns the length of the string s, or the      |\r\n|                     | length of $0 if s is not supplied.              |\r\n'---------------------+-------------------------------------------------'\r\n| match(s, r [, a])   | Returns the position in s where the regular     |\r\n|                     | expression r occurs, or 0 if r is not present,  |\r\n|                     | and sets the values of RSTART and RLENGTH.      |\r\n|                     | Note that the argument order is the same as for |\r\n|                     | the ~ operator:  str  ~  re. If array a is      |\r\n|                     | provided, a is cleared and then elements 1      |\r\n|                     | through n are filled with the portions of s     |\r\n|                     | that match the corresponding parenthesized      |\r\n|                     | subexpression in r.  The 0'th element of a      |\r\n|                     | contains the portion of s matched by the entire |\r\n|                     | regular expression r. Subscripts a[n, \"start\"], |\r\n|                     | and a[n, \"length\"] provide the starting index   |\r\n|                     | in the string and length respectively, of each  |\r\n|                     | matching substring.                             |\r\n'---------------------+-------------------------------------------------'\r\n| split(s, a [, r])   | Splits the string s into the array a on the     |\r\n|                     | regular expression r, and returns the number of |\r\n|                     | fields. If r is omitted, FS is used instead.    |\r\n|                     | The array a is cleared first. Splitting behaves |\r\n|                     | identically to field splitting.                 |\r\n'---------------------+-------------------------------------------------'\r\n| sprintf(fmt,        | Prints expr-list according to fmt, and returns  |\r\n|   expr-list)        | the resulting string.                           |\r\n'---------------------+-------------------------------------------------'\r\n| strtonum(str)       | Examines str, and returns its numeric value.    |\r\n|                     | If str begins with a leading 0, strtonum()      |\r\n|                     | assumes that  str is an octal number. If str    |\r\n|                     | begins with a leading 0x or 0X, strtonum()      |\r\n|                     | assumes that str is a hexadecimal number.       |\r\n'---------------------+-------------------------------------------------'\r\n| sub(r, s [, t])     | Just like gsub(), but only the first matching   |\r\n|                     | substring is replaced.                          |\r\n'---------------------+-------------------------------------------------'\r\n| substr(s, i [, n])  | Returns the at most n-character substring of s  |\r\n|                     | starting at i.  If n is omitted, the rest of s  |\r\n|                     | is used.                                        |\r\n'---------------------+-------------------------------------------------'\r\n| tolower(str)        | Returns a copy of the string str, with all the  |\r\n|                     | upper-case characters in str translated to      |\r\n|                     | their corresponding lower-case counterparts.    |\r\n|                     | Non-alphabetic characters are left unchanged.   |\r\n'---------------------+-------------------------------------------------'\r\n| toupper(str)        | Returns a copy of the string str, with all the  |\r\n|                     | lower-case characters in str translated to      |\r\n|                     | their corresponding upper-case counterparts.    |\r\n|                     | Non-alphabetic characters are left unchanged.   |\r\n'---------------------'-------------------------------------------------'\r\n\r\n\r\n ============================ Time Functions ===========================\r\n\r\n.---------------------.-------------------------------------------------.\r\n|                     |                                                 |\r\n| Function            | Description                                     |\r\n|                     |                                                 |\r\n'---------------------+-------------------------------------------------'\r\n| mktime(datespec)    | Turns datespec into a time stamp of the same    |\r\n|                     | form as returned by systime(). The datespec is  |\r\n|                     | a string of the form YYYY MM DD HH MM SS[ DST]. |\r\n|                     | The contents of the string are six or seven     |\r\n|                     | numbers representing respectively the full year |\r\n|                     | including century, the month from 1 to 12, the  |\r\n|                     | day of the month from 1 to 31, the hour of the  |\r\n|                     | day from 0 to 23, the minute from 0 to 59, and  |\r\n|                     | the second from 0 to 60, and an optional        |\r\n|                     | daylight saving flag. The values of these       |\r\n|                     | numbers need not be within the ranges           |\r\n|                     | specified; for example, an hour of -1 means 1   |\r\n|                     | hour before midnight. The origin-zero Gregorian |\r\n|                     | calendar is assumed, with year 0 preceding year |\r\n|                     | 1 and year -1 preceding year 0. The time is     |\r\n|                     | assumed to be in the local timezone. If the     |\r\n|                     | daylight saving flag is positive, the time is   |\r\n|                     | assumed to be daylight saving time; if zero,    |\r\n|                     | the time is assumed to be standard time; and if |\r\n|                     | negative (the default), mktime() attempts to    |\r\n|                     | determine whether daylight saving time is in    |\r\n|                     | effect for the specified time. If datespec does |\r\n|                     | not contain enough elements or if the resulting |\r\n|                     | time is out of range, mktime() returns -1.      |\r\n'---------------------+-------------------------------------------------'\r\n| strftime([format    | Formats timestamp according to the              |\r\n|   [, timestamp]])   | specification in format. The timestamp should   |\r\n|                     | be of the same form as returned by systime().   |\r\n|                     | If timestamp is missing, the current time of    |\r\n|                     | day is used.If format is missing, a default     |\r\n|                     | format equivalent to the output of date(1) is   |\r\n|                     | used.  See the specification for the strftime() |\r\n|                     | function in ANSI C for the format conversions   |\r\n|                     | that are guaranteed to be available. A          |\r\n|                     | public-domain version of strftime(3) and a man  |\r\n|                     | page for it come with gawk; if that version was |\r\n|                     | used to build gawk, then all of the conversions |\r\n|                     | described in that man page are available to     |\r\n|                     | gawk.                                           |\r\n'---------------------+-------------------------------------------------'\r\n| systime()           | Returns the current time of day as the number   |\r\n|                     | of seconds since the Epoch (1970-01-01 00:00:00 |\r\n|                     | UTC on POSIX systems).                          |\r\n'---------------------'-------------------------------------------------'\r\n\r\n\r\n =============== Internationalization (I18N)  Functions ================\r\n\r\n.---------------------.-------------------------------------------------.\r\n|                     |                                                 |\r\n| Function            |                                                 |\r\n|                     |                                                 |\r\n| Description         |                                                 |\r\n|                     |                                                 |\r\n'---------------------+-------------------------------------------------'\r\n| bindtextdomain(directory [, domain])                                  |\r\n|                                                                       |\r\n| Specifies the directory where gawk looks for the .mo files. It        |\r\n| returns the directory where domain is ``bound.'' The default domain   |\r\n| is the value of TEXTDOMAIN.  If directory is the null string (\"\"),    |\r\n| then bindtextdomain() returns the current binding for the given domain|\r\n'---------------------+-------------------------------------------------'\r\n| dcgettext(string [, domain [, category]])                             |\r\n|                                                                       |\r\n| Returns the translation of string in text domain domain for locale    |\r\n| category category. The default value for domain is the current value  |\r\n| of TEXTDOMAIN. The default value for category is \"LC_MESSAGES\". If    |\r\n| you supply a value for category, it must be a string equal to one of  |\r\n| the known locale categories. You must also supply a text domain. Use  |\r\n| TEXTDOMAIN if you want to use the current domain.                     |\r\n'---------------------+-------------------------------------------------'\r\n| dcngettext(string1 , string2 , number [, domain [, category]])        |\r\n|                                                                       |\r\n| Returns the plural form used for number of the translation of string1 |\r\n| and string2 in text domain domain for locale category category. The   |\r\n| default value for domain is the current value of TEXTDOMAIN. The      |\r\n| default value for category is \"LC_MESSAGES\". If you supply a value    |\r\n| for category, it must be a string equal to one of the known locale    |\r\n| categories. You must also supply a text domain. Use TEXTDOMAIN if     |\r\n| you want to use the current domain.                                   |\r\n'---------------------'-------------------------------------------------'\r\n\r\n\r\n\r\n\r\n =============== GNU AWK's Command Line Argument Summary ===============\r\n\r\n.-------------------------.---------------------------------------------.\r\n|                         |                                             |\r\n| Argument                | Description                                 |\r\n|                         |                                             |\r\n'-------------------------+---------------------------------------------'\r\n| -F fs                   | Use fs for the input field separator        |\r\n| --field-sepearator fs   | (the value of the FS predefined variable).  |\r\n'-------------------------+---------------------------------------------'\r\n| -v var=val              | Assign the value val to the variable var,   |\r\n| --assign var=val        | before execution of the program begins.     |\r\n|                         | Such variable values are available to the   |\r\n|                         | BEGIN block of an AWK program.              |\r\n'-------------------------+---------------------------------------------'\r\n| -f program-file         | Read the AWK program source from the file   |\r\n| --file program-file     | program-file, instead of from the first     |\r\n|                         | command line argument. Multiple -f          |\r\n|                         | (or --file) options may be used.            |\r\n'-------------------------+---------------------------------------------'\r\n| -mf NNN                 | Set various memory limits to the value NNN. |\r\n| -mr NNN                 | The f flag sets the maximum number of       |\r\n|                         | fields, and the r flag sets the maximum     |\r\n|                         | record size. (Ignored by gawk, since gawk   |\r\n|                         | has no pre-defined limits)                  |\r\n'-------------------------+---------------------------------------------'\r\n| -W compat               | Run in compatibility mode. In compatibility |\r\n| -W traditional          | mode, gawk behaves identically to UNIX awk; |\r\n| --compat--traditional   | none of the GNU-specific extensions are     |\r\n|                         | recognized.                                 |\r\n'-------------------------+---------------------------------------------'\r\n| -W copyleft             | Print the short version of the GNU copyright|\r\n| -W copyright            | information message on the standard output  |\r\n| --copyleft              | and exit successfully.                      |\r\n| --copyright             |                                             |\r\n'-------------------------+---------------------------------------------'\r\n| -W dump-variables[=file]| Print a sorted list of global variables,    |\r\n| --dump-variables[=file] | their types and final values to file. If no |\r\n|                         | file is provided, gawk uses a file named    |\r\n|                         | awkvars.out in the current directory.       |\r\n'-------------------------+---------------------------------------------'\r\n| -W help                 | Print a relatively short summary of the     |\r\n| -W usage                | available options on the standard output.   |\r\n| --help                  |                                             |\r\n| --usage                 |                                             |\r\n'-------------------------+---------------------------------------------'\r\n|-W lint[=value]          | Provide warnings about constructs that      |\r\n|--lint[=value]           | are dubious or non-portable to other AWK    |\r\n|                         | impl?s. With argument fatal, lint warnings  |\r\n|                         | become fatal errors. With an optional       |\r\n|                         | argument of invalid, only warnings about    |\r\n|                         | things that are actually invalid are        |\r\n|                         | issued. (This is not fully implemented yet.)|\r\n'-------------------------+---------------------------------------------'\r\n| -W lint-old--lint-old   | Provide warnings about constructs that are  |\r\n|                         | not portable to the original version of     |\r\n|                         | Unix awk.                                   |\r\n'-------------------------+---------------------------------------------'\r\n| -W gen-po--gen-po       | Scan and parse the AWK program, and         |\r\n|                         | generate a GNU .po format file on standard  |\r\n|                         | output with entries for all localizable     |\r\n|                         | strings in the program. The program itself  |\r\n|                         | is not executed.                            |\r\n'-------------------------+---------------------------------------------'\r\n| -W non-decimal-data     | Recognize octal and hexadecimal values in   |\r\n| --non-decimal-data      | input data.                                 |\r\n'-------------------------+---------------------------------------------'\r\n| -W posix--posix         | This turns on compatibility mode, with the  |\r\n|                         | following additional restrictions:          |\r\n|                         | o  \\x escape sequences are not recognized.  |\r\n|                         | o  Only space and tab act as field          |\r\n|                         |    separators when FS is set to a single    |\r\n|                         |    space, new-line does not.                |\r\n|                         | o  You cannot continue lines after ? and :. |\r\n|                         | o  The synonym func for the keyword function|\r\n|                         |    is not recognized.                       |\r\n|                         | o  The operators ** and **= cannot be used  |\r\n|                         |    in place of ^ and ^=.?  The fflush()     |\r\n|                         |    function is not available.               |\r\n'-------------------------+---------------------------------------------'\r\n| -W profile[=prof_file]  | Send profiling data to prof_file.           |\r\n| --profile[=prof_file]   | The default is awkprof.out. When run with   |\r\n|                         | gawk, the profile is just a \"pretty         |\r\n|                         | printed\" version of the program. When run   |\r\n|                         | with pgawk, the profile contains execution  |\r\n|                         | counts of each statement in the program     |\r\n|                         | in the left margin and function call counts |\r\n|                         | for each user-defined function.             |\r\n'-------------------------+---------------------------------------------'\r\n| -W re-interval          | Enable the use of interval expressions in   |\r\n| --re-interval           | regular expression matching. Interval       |\r\n|                         | expressions were not traditionally          |\r\n|                         | available in the AWK language.              |\r\n'-------------------------+---------------------------------------------'\r\n| -W source program-text  | Use program-text as AWK program source      |\r\n| --source program-text   | code. This option allows the easy           |\r\n|                         | intermixing of library functions (used via  |\r\n|                         | the -f and --file options) with source code |\r\n|                         | entered on the command line.                |\r\n'-------------------------+---------------------------------------------'\r\n| -W version              | Print version information for this          |\r\n| --version               | particular copy of gawk on the standard     |\r\n|                         | output.                                     |\r\n'-------------------------+---------------------------------------------'\r\n| --                      | Signal the end of options. This is useful   |\r\n|                         | to allow further arguments to the AWK       |\r\n|                         | program itself to start with a \"-\". This    |\r\n|                         | is mainly for consistency with the argument |\r\n|                         | parsing convention used by most other POSIX |\r\n|                         | programs.                                   |\r\n'-------------------------'---------------------------------------------'\r\n\r\n =======================================================================\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>.&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;. | | | AWK Cheat Sheet | | | &#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#8216; | Peteris Krumins (peter@catonmat.net), 2007.08.22 | | http:\/\/www.catonmat.net &#8211; good coders code, great reuse | &#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#8216; ===================== Predefined Variable Summary ===================== .&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;.&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;. | | | Support: | | Variable | Description &#8216;&#8212;&#8211;.&#8212;&#8212;-.&#8212;&#8212;-&#8216; | | | AWK | NAWK | GAWK | &#8216;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8211;+&#8212;&#8212;-+&#8212;&#8212;-&#8216; | FS [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[47],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3486"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3486"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3486\/revisions"}],"predecessor-version":[{"id":3487,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3486\/revisions\/3487"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}