[darcs-users] Re: a bash tip for easily excluding the _darcs directory
ralph at inputplus.co.uk
Wed Mar 9 16:10:44 UTC 2005
> find . -path '*/_darcs/*' -prune -o -print0 | xargs -0 grep string
> > I also wasn't clear what '/dev/null' did, so I removed it. :)
> It prevents grep reading from stdin if find doesn't match anything.
> This should never happen though because find will always match at
> least '.'.
It also makes grep print the filename of the matching file if xargs has
supplied just one file. `grep pat foo' doesn't prefix the matching
lines with `foo:'.
If grep were to read from stdin it would snaffle some of find's output
from xargs which wouldn't be welcome.
$ seq 1 10000 | xargs perl -le "system('cat -n')" | sed 3q
And it's not really a good idea to pass lots of directory names to grep.
Some greps don't like it. Some Unixes let you read a directory as if
it's a binary file of (inode, filename) tuples. find can easily filter
those out with -file.
More information about the darcs-users