Episodes about using Awk, the text manipulation language. It comes in various forms called awk, nawk, mawk and gawk, but the standard version on Linux is GNU Awk (gawk). It's a programming language optimised for the manipulation of delimited text.
This is obvious, but it tripped me up a few times after listening to the excellent Awk series by Dave and B-yeezi, so I though I'd share it here to save others the trouble.
When moving from simple awk commands to proper awk scripts, you put a shebang line at the top of your script. It's pretty common to many of us, because we do it for Python and Bash all the time.
But if you just put:
Then your awk script won't work the way you expect.
You must provide the -f flag:
Now you can pipe things to your awk script as expected.
Comment #1 posted on 2018-08-12 14:43:55 by Dave Morriss
Thanks for this
Thanks for this heads-up. It *is* a confusing feature of awk, but it's the same for sed (so at least the authors are consistent). I don't think we have emphasised it enough, on reflection.
It was highlighted in show 2 of the Awk series (https://hackerpublicradio.org/eps/hpr2129/full_shownotes.html#more-about-awk-programs) and has been used many times thereafter, but hasn't been emphasised.
So, thanks again for the feedback. It's most appreciated.
Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.
Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).