Hacker News new | past | comments | ask | show | jobs | submit login
Announcing my first e-book "Awk One-Liners Explained" (catonmat.net)
107 points by pkrumins on June 20, 2011 | hide | past | favorite | 24 comments



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.


You sound like an exact match of the audience of this book.


True, true. I am updating the page right now with a more appetizing example.

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.


That would be an interesting site idea in itself.

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.commandlinefu.com/ does something close to this.


Also check out the "CommandLineFu One-Liners Explained" article series of mine:

http://www.catonmat.net/blog/top-ten-one-liners-from-command...


pkrumins, out of curiosity (and the suspicion that you probably have ;-), have you written up you ebook publishing process?


I have not yet written about it, but I will do that in a bit! The whole process was very interesting!


I'd love to hear about it too.

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.


Really? The reason I should learn awk is "why not?" That has to be one of the worst reasons ever.

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.


> bashing awk

I know this was an unintentional pun, but I still thought it was funny.


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 resent the use of the word "baby" -- I have seen entire quantitative trading platforms built in awk


Perhaps the ETrade baby uses that program? (ducks)


That was my reason, cause I love to learn everything. Why not learn everything? :)

I'll update the page with a more compelling reason. Thanks for bringing this up.


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.


There are a lot of hacker types, myself and many friends included, for which "why not" is the reason we learn most of the things we do.

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 suddenly have a desire to write a companion piece based on my experiences talking with women I just met: "Awkward one-liners explained."


inserts coin


insert coins, get pdf ebooks.



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.


Why's that?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: