rak icon indicating copy to clipboard operation
rak copied to clipboard

Examples: Grep

Open sirupsen opened this issue 14 years ago • 5 comments

I recall in grep you can do:

$ grep -r pattern

Rather than:

$ grep pattern $(find . | grep -v .svn)

As shown in the examples -- or am I getting something wrong here?

sirupsen avatar Jul 24 '10 09:07 sirupsen

Yes. But the first one wouldn't exclude svn directories, would it?

danlucraft avatar Jul 24 '10 09:07 danlucraft

Ah -- that might be right -- but who uses SVN anyway?

On a serious note: --exclude-dir=.svn

sirupsen avatar Jul 24 '10 09:07 sirupsen

I don't have that option in my grep. But I think I can do --exclude=.svn, possibly.

danlucraft avatar Jul 24 '10 09:07 danlucraft

Possibly -- I'm running grep 2.6.3.

I'm sure --exclude=.svn would work as well; --excude-dir was just more explicit. :)

sirupsen avatar Jul 24 '10 10:07 sirupsen

grep pattern (find . | grep -v .svn) won't really work:

  • It will die with "Argument list too long" if you're grepping even moderately sized source tree. ARGV limits are puny - 128kB on Linux, 256kB on OSX.
  • It will also fail if you have any funny characters in your paths, where even space is considered funny.

taw avatar Jul 27 '10 08:07 taw