Web lists-archives.com

Re: An appropriate directory search tool?




On Sun 21 Oct 2018 at 05:25:05 (-0500), Richard Owlett wrote:
> On 10/20/2018 08:16 PM, John Crawley wrote:
> > On 20/10/2018 19.28, Richard Owlett wrote:
> > > ...I would have expected to use an explicit pipe command
> > > between 'find' and 'grep'.
> > 
> > In fact, depending on the exact conditions of your search, you
> > might not need to use find at all. 'grep -r' will do a recursive
> > search, starting at whatever directory you give it, looking inside
> > every file for some content. Like:
> > 
> > grep -r 'keyword_or_regex' dirname
> > 
> > Of course, 'man grep' for various options...
> > 
> 
> I wish a list of files with a specific extension in a directory which
> contain keywordA but not keywordB. Recursing down the directory tree
> was the primary objection to the MATE search tool.

At last, a direct question!

$ grep -L keywordB $(grep -l keywordA a-directory/*extension)

Mix with quotes according to taste and needs.

Cheers,
David.