Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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...




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

Search: