Re: Searching with Boolean Expressions
- Flo wrote:
>Findstr operates in the context of individual lines within files, so to implement "aaaaa NOT (bbbbb AND ccccc)" for entire files, I'd probably (at first glance) build the list of files containing "aaaaa" first:
> Now we want to find 'aaaaa' but exclude files containing 'bbbbb' and 'ccccc'. With Agent Ransack, it works with...
> 'aaaaa NOT (bbbbb AND ccccc)'
findstr /m aaaaa
Then remove dupes, preserve the remnants for the last step and look among them for the first condition of exclusion:
findstr /m bbbbb
And then among the resulting list of files for the second condition:
findstr /m cccccc
Where I'd simply end up with any filenames to remove from the first list.
Achieving it with a single fancy long-winded call to cmd is probably not for the faint of heart, so I'd either make a .bat or just let Clip manipulate variables and act as glue between the blazing searches.
To answer your question, Flo, I don't see an AND provision within the Findstr itself, but command redirection operators (&, &&, | and ||) afford plenty of Boolean logic.
- Duh! I need more sleep. Or need to grow younger.
I had just read that an hour earlier.
In one eye and out the hole in my head!!!
At 05/17/2011 07:49, diodeom wrote:
> > So to accomplish your expression use FINDSTR three times - once to
> > extract all "x"s, then to exclude all "y"s and finally to exclude all "z"s
> > piping the output each time to the next step. Each pipe is like an AND.
> > findstr x | findstr /v y | findstr /v z
>One can find lines not containing y's or z's in one shot by findstr /v "y
>z" where the space serves as OR in this notation. (By contrast, the
>following locates any lines without the literal "y z" string: findstr /v