Quincy Center for Technical Education
Computer Technology Department

Findstr

Searches for strings in files using literal text or regular expressions. Click Devinfo Notes in the Related Topics list for a list of the regular expression symbols accepted by findstr.

findstr [/b] [/e] [/l] [/c:string] [/r] [/s] [/i] [/x] [/v] [/n] [/m] [/o] [/g:file] [/f:file] [/d:dirlist] [/a:color attribute] [strings] [[drive:][path] filename [...]]

Parameters

/b

Matches the pattern if at the beginning of a line.

/e

Matches the pattern if at the end of a line.

/l

Uses search strings literally.

/c: string

Uses specified text as a literal search string.

/r

Uses search strings as regular expressions. This switch is not required; findstr interprets all metacharacters as regular expressions unless the /l switch is used.

/s

Searches for matching files in the current directory and all subdirectories.

/i

Specifies that the search is not to be case sensitive.

/x

Prints lines that match exactly.

/v

Prints only lines that do not contain a match.

/n

Prints the line number before each line that matches.

/m

Prints only the file name if a file contains a match.

/o

Prints seek offset before each matching line.

/g file

Gets search strings from the specified file.

/f file

Reads file list from the specified file.

/d dirlist

Searches a comma-delimited list of directories.

/a color attribute

Specifies color attributes with two hexadecimal digits.

Use spaces to separate multiple search strings unless the argument is prefixed with /c, as shown in the following example:

findstr "hello there" x.y

searches for "hello" or "there" in file x.y. However, the following command searches for "hello there" in file x.y.

findstr /c:"hello there" x.y