gawk command examples
gawk – pattern scanning and processing language
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 access_log | awk '/myhome.html/ { system("nmap " $1 ">> logdir/myhome.html") }'