[SOLVED] Should I make "learn AWK" a 2018 resolution?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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!"
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 ...)
Last edited by sundialsvcs; 12-27-2017 at 01:43 PM.
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."
Er, which manual are you talking about? The gawk manual is 560 pages; I assume you're talking about a different one?
The gawk manpage from "man -t gawk" is 23 printed pages. That's all it takes to describe the whole language, and it's all I've ever needed. Ditto for several people I've worked with. One can, of course, write whole books of tutorials for ways to use awk.
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,499
Rep:
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.