I'm sure this is an awesome resource, and I really should check it out since I want to learn more of awk.
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.
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 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.
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.
I had the same question the other day, and it turned into a spontaneous all-company "why you should use awk" lesson. If this kind of thing sounds cool to you, drop me a resume at david at loggly.com. We're at 1st and Mission in SF.
Short answer, it's a baby programming language that's more powerful than sed, quicker to write than python, and less confusing than cut.
I've found that awk is one of those tools whose potential use becomes clear only after putting in some initial effort to learn it. Along with sed, sort, and others, awk has solved problems for me that would have otherwise been extremely tedious.
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.
Manuals are good once you already know something or if you want to become an expert. I don't think either of these are the buyer of the one-liner book. The one-liner buyer is a person who has the occasional need to script and doesn't want to have to become an expert again every time they need to do something.
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.
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.