Thanks, abcuser; this was quite comprehensive. The only addition I would make is to assure that gawk is installed:
sudo apt-get install gawk
I expect many users already have it, though it wasn't...