Live data from Hacker News

Use ack instead of grep to parse text files

stevengharms.com

21–30 of 51 posts

Re: Use ack instead of grep to parse text files

#23
A little feedback on voice. When someone says "You should stop using them. Now.", I expect the article to be about some system killing security problem, not an argument for the elegance of one tool over another. And if the argument is going to be about elegance, it better be absolutely compelling. The benefit of piped grep expressions is that you don't have to know anything beyond the principles of Unix to intuit their usage. For many uses (most uses for me), no thought is required -- grep fades into the background and becomes part of the programmatic brain stem. Commanding the reader to no longer use it is as effective as telling them to stop breathing.

Re: Use ack instead of grep to parse text files

#24
post #4

This article is a wonderful demonstration why simple methods piped together is better and easier to use than a giant monolithic application like awk.

Are you confusing awk with ack?

I confused the apps in the text but the point was that those regexes look far worse than the equivalent grep pairs.

Re: Use ack instead of grep to parse text files

#26
post #4

This article is a wonderful demonstration why simple methods piped together is better and easier to use than a giant monolithic application like awk.

Are you confusing awk with ack?

It sounds like it.

But that too seems like a demonstration of something. The more "simple" methods with obscure names that populate the Unix toolbox, the more confusing it gets. I've gone from find to locate recently, for example, but their functionalities kind of overlap and so when I do find, I'm rusty with it.

Re: Use ack instead of grep to parse text files

#29
grep has the great strength of near-ubiquitous installation. If you find yourself on a Unix-like system, it will have grep. Perhaps if you only ever really work on a very small set of systems, then this doesn't matter, but for those of us who frequently need to work on different systems and don't always have the ability to install new packages, grep does a fine job. In fact, it has a lot in common with vi here: you can (nearly) always count on having it available.

Re: Use ack instead of grep to parse text files

#30

>The primary virtue of these commands is that they use the Perl regular expression engine. You mean the engine that lets you write pathological regular expressions[1] and accidentally ReDoS[2] yourself? To be fair, it's fine if you understand how the engine works well enough to avoid these cases. But how many people can actually say this? 1. http://swtch.com/~rsc/regexp/regexp1.html 2. http://en.wikipedia.org/wiki/Re…

I was looking into breaking a Perl IRC bot the other day and couldn't get any of the examples to work (that is, take more than a split second to execute). Does perl now detect these pathological cases and work around them or was I just not trying the examples correctly?

I believe I read somewhere that recent versions of Perl detect certain obviously pathological cases and abort them, but I don't know if they fail silently or display an error. Whether a particular needle is pathological depends on the haystack, too, so it could just be that there was a mismatch between the two in your case.
Post reply on HN