Some Technical Details on AWK

Many of you know that I’m a big fan of AWK. After Lisp and C, it’s my go to language, especially for scripts that involve reading a bunch of lines and performing some sort of regex-mediated action on them. Its language is basically C-like but there are some anomalies that can seem mysterious.

Volodymyr Gubarkov has a project to provide an InteliJ plug in for AWK and part of that requires parsing AWK syntax so he has a good handle on those anomalies and why they exist. He discusses those peculiarities in his post, AWK technical notes.

It’s an interesting post that explains many things that you probably didn’t know about AWK. In a way, it’s getting into the weeds but it also increases your understanding of the way things work and allows you to write better AWK.

For example, one thing I didn’t know was that although it’s illegal to have a space between a user defined function and its argument list, it is legal to have a space between a built in function and its argument list. The reason for that involves string concatenation. Take a look at Gubarkov’s post for the details.

The post mentions some other interesting anomalies in the AWK syntax and the reasons for them. If you use AWK, it’s definitely worth reading the post if only to be aware of the gotchas waiting for the unwary.

This entry was posted in General and tagged . Bookmark the permalink.