Web lists-archives.com

Re: An appropriate directory search tool?




On Fri, Oct 19, 2018 at 11:12:30AM -0400, Roberto C. Sánchez wrote:
> On Fri, Oct 19, 2018 at 10:00:25AM -0500, Richard Owlett wrote:
> > The "MATE Search Tool" comes close.
> > 
> > It can:
> >   Select a starting directory.
> >   Search for a specific extension.
> >   Search for a keyword in file content.
> > 
I missed your keyword search requirement.

> > It cannot:
> >    Search ONLY the specified directory.
> >    Return files that DO NOT contain a keyword.
> > 
> > I suspect what I want would most likely be what I'm looking for.
> > "ls" can search by extension and stay in specified directory.
> > It cannot include/exclude keywords.
> > 
> > My immediate problem involves only a couple dozen files so manual search is
> > feasible.
> > 
> > Suggestions?
> 
> I recommend 'find' run from the terminal.
> 
> For example, I have a directory tree full of files like shell scripts,
> Perl scripts, and also XML documents and their Russian translations.  To
> find the XML documents that are not Russian translations, I can do this:
> 
> find . -name '*.xml' -a \! -name '*_ru.xml'
> 
I would modify the above command like this:

find . -name '*.xml' -a \! -name '*_ru.xml' -exec grep -Hn '<year>2003-2005</year>' {} \;

> Read that as "find, the current director, files named *.xml and not
> named *_ru.xml."
> 
Which would then change the reading to "find, the current director,
files named *.xml and not named *_ru.xml that contains the string
'<year>2003-2005</year>'." (the -Hn options to grep tell it to display
the file name and line number of each match)

> It also supports an amazing array of conditions, like newer/older than,
> same/different permissions, size, etc.
> 
> Regards,
> 
> -Roberto
> -- 
> Roberto C. Sánchez
> 

-- 
Roberto C. Sánchez