Linux "mawk" Command Line Options and Examples
pattern scanning and text processing language

mawk is an interpreter for the AWK Programming Language. The AWK language is useful for manipulation of data files, text retrieval and processing, and for prototyping and experimenting with algorithms. mawk is a new awk meaning it implements the AWK language as defined in Aho, Kernighan and Weinberger, The AWK Programming Language, Addison-Wesley Publishing, 1988.


mawk [-W option] [-F value] [-v var=value] [--] 'program text' [file ...]
    mawk [-W option] [-F value] [-v var=value] [-f program-file] [--] [file ...]

Command Line Options:

value sets the field separator, FS, to value.
mawk -F ...
file Program text is read from file instead of from the command line. Multiple -f options are allowed.
mawk -f ...
var=value assigns value to program variable var.
mawk -v ...
The above options will be available with any Posix compatible implementation of AWK, and implementation specific options are prefacedwith -W. mawk provides six:
mawk -- ...
version mawk writes its version and copyright to stdout and compiled limits to stderr and exits 0.
mawk -W ...
Every string, including the empty string, matches the empty string at the front so, s ~ // and s ~ "", are always 1 as ismatch(s, //) and match(s, ""). The last two set RLENGTH to 0.index(s, t) is always the same as match(s, t1) where t1 is the same as t with metacharacters escaped. Hence consistency withmatch requires that index(s, "") always returns 1. Also the condition, index(s,t) != 0 if and only t is a substring of s,requires index("","") = 1.If getline encounters end of file, getline var, leaves var unchanged. Similarly, on entry to the END actions, $0, the fieldsand NF have their value unaltered from the last record.
mawk -4, ...