This is an old revision of the document!
Awk
AWK is a pattern scanning and processing language. Gawk is the GNU Project's implementation of the AWK programming language.
I typically stick to using gawk and in most cases, awk is a symlink to gawk. This page will contain useful gawk commands as I run into them.
gsub
gawk's gsub string function matches and replaces regular expressions. This can replace a grep | sed combination.
~$ echo -e "Hello, friend.\nHello, how are you?\nI am fine." | gawk 'gsub(/Hello/,"Goodbye")' Goodbye, friend. Goodbye, how are you?
Notice that the last line “I am fine.” is not displayed at all because it doesn't match the regex. (Hello)