4 ms·
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 b
by unwind 15y ago
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.
- forkrulassail 15y agoThat 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.
- sciurus 15y agohttp://www.commandlinefu.com/ http://www.commandlinefu.com/ does something close to this.
- pkrumins 15y agoAlso check out the "CommandLineFu One-Liners Explained" article series of mine: http://www.catonmat.net/blog/top-ten-one-liners-from-commandlinefu-explained/ http://www.catonmat.net/blog/top-ten-one-liners-from-command...
- hugh3 15y agoTo 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.
- kisielk 15y agoYou sound like an exact match of the audience of this book.
- pkrumins 15y agoTrue, 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.