Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Glob and grep



Dominik Vogt wrote on Tue, Dec 17, 2019 at 00:24:27 +0100:
> On 12/16/19, Nick Cross <zsh@xxxxxxxxx> wrote:
> > While I've been able to find varying amounts of information on the net I
> > haven't found quite enough to get the following working.
> >
> > I would like to condense the following into a single grep / glob
> > expression where I search recursively through a directory tree, ignoring
> > any sub-trees starting with 'test' or 'target'.
> >
> > grep <pattern> **/*.groovy  | egrep -v "(/test/|/target/)"
> 
> Or a zsh-less solution:
> 
>  $ grep -R --include="*.groovy" --exclude-dir=test --exclude-dir=target a .

If the tree is in version control, there's another way:

rm -rf **/(test|target)(N)
grep needle **/.haystack
<restore the deleted files>



Messages sorted by: Reverse Date, Date, Thread, Author