The example: "find . -name '* .py' | xargs grep 'import'" would become "find . -name '* .py' -exec grep -H 'import' {} \;".
You need to include the -H in grep to get the filename in which the match occurs.
The example: "find . -name '* .py' | xargs grep 'import'" would become "find . -name '* .py' -exec grep -H 'import' {} \;".
You need to include the -H in grep to get the filename in which the match occurs.
Also note that text surrounded by asterisks in your comment become italics. Indent text by two or more spaces to reproduce text verbatim, like for code.
It's not necessarily about saving a pipe, but also, when the tool provide first-class support for the function, it's typically less prone to error. For example, the -print0 becomes unnecessary, and I've been burnt by that.
I also appreciate the writeups that don't teach poor examples. We all know how prolific copy&paste coding is. How many times have you seen "grep foo bar | wc -l" when you know it's just all-around better to "grep -c foo bar"?
I think a good intro to xargs starts with a list of things that you can't do without it. (Easy for me to say that, but of course I haven't written that piece...) It'd be great to know why to use it, not just how, you know what I mean?
Anyway, this is just off-the-cuff commentary, not criticism. Thanks for writing it up.
grep import **/*.pyPlus it has --thpppt.
They already had a package named ack. WTF? By "getting their priorities" correct you mean catering to you?
The same problem is currently happening with node.js. Its unfortunate that node.js chose node to replace an equally ambiguous and generic name.
That being said, yes, I believe they're plain wrong on this one. They shouldn't cater to me, but to their users. Thank God they have stats.
http://qa.debian.org/popcon.php?package=ack-grep
http://qa.debian.org/popcon.php?package=ack
I count in both because I installed the ack package mistakingly. I'm probably not the only one.
Still a very large WIN for ack, the one I care about.
I usually don't bother with this kind of command line micro-optimization, but in my experience find and grep are the commands for which it's worth knowing and using every option.
So maybe a 1000 grep processes instead of one. But I've saved a pipe.