Search notes:

awk

awk [POSIX or GNU style options] -f progfile [--] file …
awk [POSIX or GNU style options] [--] 'program' file …

Options

POSIX options

-f progfile --file=progfile
-F fs --field-separator=fs
-v var=val --assign=var=val

Other options?

-b --characters-as-bytes
-c --traditional
-C --copyright
-d --dump-variables [file]
-D --debug [file]
-e --source= 'program-text'
-E --exec= file
-g --gen-pot
-h --help
-i --include= includefile
-l --load= library
-L --lint[=] [fatal|invalid|no-ext]
-M --bignum
-N --use-lc-numeric
-n --non-decimal-data
-o --pretty-print[=] [file]
-O --optimize
-p --profile[=] [file]
-P --posix
-r --re-interval
-s --no-optimize
-S --sandbox
-t --lint-old
-V --version
-W -W followed by the name of a long option, is used in gawk for POSIX compatiblity.

Variables

Some interesting variables include:
NR The cumulative processed record number, starting with 1 ls -1 | awk '{ printf("%2d %s\n", NR, $0) }'
FNR The record number of the currently processed file
$n The n-th field in the current record, for n = 0, the entire record. $FS refers to the last field (see NF) ls -l | awk '{ print $3 " " $9 }'
NF Number of fields head -1 /etc/passwd | awk -F: '{ print NF }'
FILENAME Name of the current input file
OFS Output field separator

-W

-W is followed by the name of a long option.
In GAWK, this option is used for POSIX compatibility.
$ awk --version
awk: not an option: --version

$ awk -W version
mawk 1.3.4 20200120
…

$ sudo apt install -y gawk
…

$ awk --version
GNU Awk 5.1.0, API: 3.0 (GNU MPFR 4.1.0, GNU MP 6.2.1)
…

$ awk -W version
GNU Awk 5.1.0, API: 3.0 (GNU MPFR 4.1.0, GNU MP 6.2.1)
…

Misc

Unfortunately, awk does not support Perl style regular expressions.

See also

awk examples
cut
Using awk to create a left aligned output of mount.
Other programming languages etc.

Links

https://github.com/ReneNyffenegger/about-awk

Index