batch-filecmdfindstr

Why doesn't this FINDSTR example with multiple literal search strings find a match?


Sometimes FINDSTR with multiple literal search strings fails to find all matches. For example, the following FINDSTR example fails to find a match.

echo ffffaaa|findstr /l "ffffaaa faffaffddd"

Why?


Solution

  • Apparantly this is a long standing FINDSTR bug. I think it can be a crippling bug, depending on the circumstances.

    I have confirmed the command fails on two different Vista machines, a Windows 7 machine, and an XP machine. I found this findstr - broken ??? link that reports a similar search fails on Windows Server 2003, but it succeeds on Windows 2000.

    I've done a number of experiments and it seems all of the following conditions must be met for the potential of a failure:

    In every failure I have seen, it is always one of the shorter search strings that fails.

    It does not matter how the search strings are specified. The same faulty result is achieved using multiple /C:"search" options and also with the /G:file option.

    The only 3 workarounds I have been able to come up with are:

    I hate this bug!!!!

    Note - See What are the undocumented features and limitations of the Windows FINDSTR command? for a comprehensive list of FINDSTR idiosyncrasies.