[darcs-users] a bash tip for easily excluding the _darcs directory

Mark Stosberg mark at summersault.com
Tue Mar 8 20:14:22 UTC 2005

I often want to grep through my tree for a string.
A simple way to do this is do a recursive grep from the 
top of the tree:

grep -R string *

That will of course find lots of matches in _darcs that I don't want.

So I could do this:

grep -R string * | grep -v _darcs 

But I still have a performance penalty of looking through that whole

The bash shell has a lesser known option for just this case. It's called
'extglob'. You can see if you have present and turned on like this:

shopt extglob

You can set it in your session or bash .profile like this:

shopt -s extglob

Now, the grand finale:

grep -R string !(_darcs)

That will grep through everything except the darcs directory. 


If this was useful to you, consider adding it to the wiki somewhere. 


More information about the darcs-users mailing list