💾 Archived View for jsreed5.org › log › 2024 › 202405 › 20240519-eyeing-awk.gmi captured on 2024-06-16 at 12:30:19. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2024-05-26)
-=-=-=-=-=-=-
---
I use Linux on my home computers as well as at my job. I've learned how to use a lot of tools along the way, but there are many tricks and programs that I still don't know much about. One of those programs is awk.
Most of my computing activities take place in the terminal, and as such, I work with text almost all the time. When I write scripts, the bulk of the commands simply print, parse, perform actions on, and prettify text. I first learned how to work with text in Linux using grep and sed, and to this day, those are the tools I reach for first when I need to process textual data.
grep and sed are great tools, but they can only do so much. sed was never really intended to do more than modify text within the bounds of regex, and grep wasn't really designed to do more than match text. Sometimes I find myself needing to do something fancy: print a line of text after a match, get the fourth field in one file but the tenth in another, and so on.
One can chain grep and sed together to do such tasks, but they often require some sort of external help, like a shell variable to keep track of line numbers. It would benefit me greatly to learn a program that would allow me to do such manipulations in a more robust way.
My only problem with awk is that, like with Perl, I find the command set to be a little intimidating. It is a domain-specific language, but it is still a Turing-complete language, and learning its rules feels as daunting as trying to learn Perl--which I also never picked up.
At my last job, one of my teammates was an absolute awk guru. We had many files used by COBOL programs, and their structure lent itself well to parsing with awk. There was almost no type of file processing my coworker couldn't do with awk. I admired his skill, and I want to have the same ability.
---
[Last updated: 2024-05-19]