Loading ...
Sorry, an error occurred while loading the content.

Re: Searching with Boolean Expressions

Expand Messages
  • diodeom
    ... 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
    Message 1 of 14 , May 17, 2011
    • 0 Attachment
      Flo wrote:
      >
      > 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 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:

      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.
    • Art Kocsis
      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!!! Art
      Message 2 of 14 , May 17, 2011
      • 0 Attachment
        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!!!

        Art

        At 05/17/2011 07:49, diodeom wrote:
        >Art 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
        >/c:"y z")
      Your message has been successfully submitted and would be delivered to recipients shortly.