Announcing my first e-book "Awk One-Liners Explained"
catonmat.net
catonmat.net
That said, I find the initial "appetizer" example a bit contrived. To print all users from /etc/password from the command-line would probably not be done by writing a C program, by most (sane) people.
I would just do "cut -d: -f1 /etc/passwd", which feels simpler than the awk example.
CommandLineAlternative.to
Shows several ways to accomplish the same thing with those closest to the minimum amount of characters and intended command line tool.
http://www.catonmat.net/blog/top-ten-one-liners-from-command...
I used to work with a guy who would have done it that way. I do admit he was not entirely sane.
Personally I'd do it with two or three lines of python rather than awk, even though I theoretically know awk, because it's quicker for me to type the Python than to remember the syntax for the awk (wait, which brackets are which again?).
That's not an argument against learning awk, of course, that's an argument for why I should learn awk slightly better.
With C example I just wanted to illustrate how long the C program would be compared to Awk, and that it makes sense to learn a scripting language.
Yeah, the `cut -d: -f1 /etc/passwd` works.
From a slightly selfish perspective, I'd love to know if you knew about Leanpub (http://leanpub.com) and, if you did, what about it made you do the work of publishing it yourself rather than going through us.
I only ask because you really fit our target author profile perfectly, and we obviously screwed something up if you knew about Leanpub and still decided to build the workflow and sales site yourself :).
If you didn't know about Leanpub, then obviously we need to market better.
Not that I am bashing awk or anything. I'm sure there are many reasons to learn it. But why not is definitely not one of them.
I know this was an unintentional pun, but I still thought it was funny.
I'll update the page with a more compelling reason. Thanks for bringing this up.
Short answer, it's a baby programming language that's more powerful than sed, quicker to write than python, and less confusing than cut.
So the reason "why not be a master the shell" seems more about saving yourself time/being more efficient/knowing the tools at your disposal.
It's partly linked to intellectual curiosity, and on the other hand partly linked to how we procrastinate/stave off boredom: learning random things.
I learned enough awk once-upon-a-time that I think the book could be very useful. I tend to do python three-liners like somebody else here mentioned, but if I had a very quick way to find the awk, I'd use it more. The problem I have is that I'm not sure an ebook makes it fast enough.