Should I make "learn AWK" a 2018 resolution?
Is AWK still useful these days?
Every time I see AWK, I just think I need to rewrite it in Python. |
It's good at getting fields/columns from text
|
The whole awk manual is just 23 pages. Contrast that with Python, ... .
|
I got by without it (avoided it) for a long time, using other scripting languages for anything sed alone could not handle.
Then after seeing my then young son slice and dice circles around some of my solutions with awk, I decided to finally learn it... It turned out to be very simple, at least the basics. You undoubtedly know regular expressions already, so you mostly need to grasp the awk processing loop, how it separates and references fields and variables, plus a few basic built-in functions, and you will begin to use it for many simple and complex tasks without much thought. You will gain proficiency with use, as with all programming languages. So learn the basics and start using it - it grows on you quickly in my experience! |
Although I would of course categorically say that "you should always familiarize yourself with yet-another tool," I would also add to this particular comment that "I often find myself using Perl, instead."
The Perl programming language really started, long ago, when a guy named Larry Wall decided that "awk" wasn't powerful enough for his purposes. So, he created a new tool that has very-obvious and very-strong ancestry to Awk ... so much so that there is even an a2p command for "converting Awk to Perl!" :eek: While I happen to find this command a bit too simple-minded, the essential idea is clear ... and, to me, compelling. Perl is a far-more powerful programming environment. (Which, to its credit and in its defense, "awk never set out to be.") All this being said, you will encounter "awk scripts" and "awk one-liners" in production code, and you therefore should familiarize yourself with this tool as-is. It is certainly a very powerful tool in its own right, and I have used it "as is" many, many times to great effect. To me, this sort of thing isn't "a New Year's resolution." It's the work of an afternoon. You'll probably find it to be the same. (Full disclosure: I am a 'language nerd.') But, y'know, when you are in this business as a means of earning your daily bread, it just never hurts to keep your pocket-protector as full of ideas as possible. ;) You never know when you'll need to use one, and "if you've already seen it, it makes you Look Very Cool.™" (In spite of the pocket-protector ...) |
Quote:
This is not the first time either. |
Quote:
|
Quote:
|
Shell, sed, & awk used to be the mainstays of unix, they can do an awful lot of things, by themselves or using pipes to other basic unix programs like uniq, etc.
Other languages have their following, but if you learn what comes with a basic unix setup, you will be able to do things on any version of unix like OSes. |
yes, sometimes awk is the right tool to implement a feature. perl/python/whatever obviously capable to do the same, but for simple tasks probably awk is even faster.
|
Thers is an in-depth series on using awk at Hacker Public Radio. If you want to learn awk, you might find it most helpful.
It's on my bucket list. |
It's worth using it. By using it, you will learn it. No tool is the final solution, there are different tools suitable for different solutions. I've found that awk is great for splitting text fields to allow me to search and replace.
|
|
Turns out it's great for parsing the output of stuff like xrandr, xset, glxinfo, xdpyinfo, etc.
|
All times are GMT -5. The time now is 03:18 PM. |