Name

find — \Windows\Command\find.exe

Synopsis

Search in one or more files for text.

To Launch

find [/v] [/c] [/n] [/i] [/offline] "string" [filename[ ...]]

Description

After searching the specified files, find displays any lines of text that contain the string you’ve specified for your search. find is useful for searching for specific words (strings) in files, but don’t get it confused with Start Search For Files or Folders (See Windows Explorer in Chapter 4), which is capable of searching for text, files, directories, etc., and has many other capabilities that the find command doesn’t have.

The find options are:

" string "

The text to look for, enclosed in quotation marks.

filename

The file(s) in which to search. Although wildcards (*, ?) are not supported, multiple filenames can be specified as long as they are separated with commas. If filename is omitted, find searches text typed at the prompt or piped from another command via the pipe character (|), as described in Section 6.3, earlier this chapter.

/c

Displays only the count of lines containing the string.

/i

Ignores the case of characters when searching for the string.

/n

Displays line numbers with the displayed lines.

/v

Displays all lines not containing the specified string.

/offline

Includes files with the offline attribute set (that otherwise would be skipped).

Examples

Search for “redflag” in myemployees.txt:

C:\>find "redflag" myexployees.txt

Count occurrences of the word “deceased” in myemployees.txt:

C:\>find /c ...

Get Windows XP in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.