Search notes:

findstr.exe

A Find String (QGREP) Utility.
findstr text *.c

Case sensitive search

By default, findstr searches case insensitively. The /i flag turns on case sensitiveness.
The following findstr command only finds «House», but neither «house» nor «HOUSE».
findstr /i House *.txt

Searching for literal string (such as strings that contain spaces)

The following search searches for lines that either contain foo or bar (or both):
findstr "foo bar" *
In order to search for a literal string (that might contain spaces, such as foo bar), the /c: modifier must be used
findstr /c:"foo bar" *

Search for text in current and sub-directories

The /s flag specifies to search in the current directory and its sub directories.
/m might be used to print the filenames only. (This option corresponds to the -l option of grep).
Search for the text «needle» in all files:
C:\path\to\some\directory> findstr /s /m needle *
Search for «needle in haystack» in *.txt files only:
C:\path\to\some\directory> findstr /s /m /c:"needle in haystack" needle *.txt
It is important to specify either * (for all files) or *.suffix (or a list of suffixes). This is different to grep -r (where the file wildcard is not required) and thus a constant source of confusion.

Regular expressions

Very rudimentary regular expressions are enabled with /r.
There is no support for
Word boundaries, however, can be matched with \< and \>, respectively.
Finding something that looks like a hexadecimal number could be achieved with character classes:[0-9A-F][0-9A-F][0-9A-F].

Using word boundaries

Word boundaries are especially useful to search for short words that might often be contained within longer words. For example, in order to search exactly for the word head (but not for header, beheaded etc.), this could be achieved with
findstr /s /r /c:"\<head\>" *

Exclude binary files

The -p option excludes files with non-printable characters (typically files containing binary data).
This setting is especially useful to suppress the beeps that are usually sounded if using findstr on binary files.
However, it is not entirely clear (at least to me) which characters are considered to be non-printable by findstr.

See also

find.exe supports UTF-16 while findstr.exe supports regular expressions.
Also, it seems that it's not possible to use the pipe with find (findstr allows to do something like dir | findstr xyz).
GNU's: grep and find.
The PowerShell equivalent for grep seems to be the cmdlet select-string.
findstr might be considered a filter operation as known in functional programming.

Index