Complete awk commands reference — 48 commands across 2 categories. Quick reference cheat sheet for Linux, macOS & BSD.
| Shortcut | Action |
|---|---|
| awk -f program-file | Read the AWK program source from the file program-file, instead of from the first command |
| awk -F fs | Use fs for the input field separator (the value of the FS predefined variable) |
| awk -v var=val | Assign the value val to the variable var, before execution of the program begins |
| awk -b | Treat all input data as single-byte characters |
| awk -c | Run in compatibility mode |
| awk -C | Print the short version of the GNU copyright information message on the standard output |
| awk -d[file] | Print a sorted list of global variables, their types and final values to file |
| awk -D[file] | Enable debugging of AWK programs |
| awk -e program-text | Use program-text as AWK program source code |
| awk -E file | Similar to -f, however, this option is the last one processed |
| awk -g | Scan and parse the AWK program, and generate a GNU .pot (Portable Object Template) format |
| awk -h | Print a relatively short summary of the available options on the standard output |
| awk -i include-file | Load an awk source library |
| awk -I | Print the internal byte code names as they are executed when running the program |
| awk -k | Enable CSV special processing |
| awk -l lib | Load a gawk extension from the shared library lib |
| awk -L [value] | Provide warnings about constructs that are dubious or non- portable to other AWK implement |
| awk -M | Force arbitrary precision arithmetic on numbers |
| awk -n | Recognize octal and hexadecimal values in input data |
| awk -N | Force gawk to use the locale's decimal point character when parsing input data |
| awk -o[file] | Output a pretty printed version of the program to file |
| awk -O | Enable gawk's default optimizations upon the internal representation of the program |
| awk -p[prof-file] | Start a profiling session, and send the profiling data to prof-file |
| awk -P | This turns on compatibility mode, and disables a number of common extensions |
| awk -r | Enable the use of interval expressions in regular expression matching |
| awk -s | Disable gawk's default optimizations upon the internal representation of the program |
| awk -S | Run gawk in sandbox mode, disabling the system() function, input redirection with getline |
| awk -t | Provide warnings about constructs that are not portable to the original version of UNIX aw |
| awk -V | Print version information for this particular copy of gawk on the standard output |
| awk -- | Signal the end of options |
| Shortcut | Action |
|---|---|
| ARGV | Array of command line arguments |
| BINMODE | On non-POSIX systems, specifies use of "binary" mode for all file I/O |
| CONVFMT | The conversion format for numbers, "%.6g", by default |
| ENVIRON | An array containing the values of the current environment |
| ERRNO | If a system error occurs either doing a redirection for getline, during a read for getline |
| FIELDWIDTHS | A whitespace-separated list of field widths |
| FILENAME | The name of the current input file |
| FPAT | A regular expression describing the contents of the fields in a record |
| FS | The input field separator, a space by default |
| FUNCTAB | An array whose indices and corresponding values are the names of all the user-defined or e |
| IGNORECASE | Controls the case-sensitivity of all regular expression and string operations |
| LINT | Provides dynamic control of the --lint option from within an AWK program |
| PREC | The working precision of arbitrary precision floating-point numbers, 53 by default |
| PROCINFO | The elements of this array provide access to information about the running AWK program |
| ROUNDMODE | The rounding mode to use for arbitrary precision arithmetic on numbers, by default "N" (IE |
| RT | The record terminator |
| RLENGTH | The length of the string matched by match(); -1 if no match |
| TEXTDOMAIN | The text domain of the AWK program; used to find the localized translations for the progra |
Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"