It has been a while so could someone remind me why awk is so fab? Perhaps it's just I've never met the right use case to make me fall in love.
Sorry if it's a dumb question. TIA
It has been a while so could someone remind me why awk is so fab? Perhaps it's just I've never met the right use case to make me fall in love.
Sorry if it's a dumb question. TIA
So if you want/need to write a script that requires more sophistication than cat, join and sort offer, but you don't want the hassle of setting up IO, field splitting, pattern matching in a more complex programming language, etc., AWK is your friend.
Some of examples of my own awk scripts: converting csv to json, counting trigrams, splitting text by words or sentences, getting the one line from a complex and long log file that I needed, pre-processing files before compilation, cross-tabulation, rewriting file paths, converting weird file formats and ad-hoc templating.
32-bit Excel used to have a limit of around 65 000 rows. 64 bit Excel is just over 1 000 000 rows. Both of these limits are commonly exceeded.
Excel requires all the data to be in memory. Awk processes line by line so requires less memory.
Awk scripts can easily be incorporated in a chain of other commands.
Version comparison is easier with Awk scripts as they are text based not binary (xls) or compressed XML (xlsx) files.
Awk can be combined with sed, uniq, sort and other tools as one-liners or in shell scripts for fast and powerful data analysis or transformation. These tools are available by default on my Unix-like operating systems.
Nowadays though, scripting languages like Perl (inspired by Awk), Python or Ruby might be used instead of Awk.
Awk has been a handy tool for me professionally a number of times when I had large amounts of textual data to analyse. I have used it many times to transform data to pass to Oil and Gas engineers who were unable to handle the raw data in Excel.
That being said, I used python in those instances, but I'm willing to believe I could've done it faster and more easily with awk.