Searches for a string of text in a file or files, and displays lines of text that contain the specified string.


find [/v] [/c] [/n] [/i] [/off[line]] <string> [[<drive>:][<path>]<filename>[...]]


Parameter Description
/v Displays all lines that don't contain the specified <string>.
/c Counts the lines that contain the specified <string> and displays the total.
/n Precedes each line with the file's line number.
/i Specifies that the search is not case-sensitive.
[/off[line]] Doesn't skip files that have the offline attribute set.
<string> Required. Specifies the group of characters (enclosed in quotation marks) that you want to search for.
[<drive>:][<path>]<filename> Specifies the location and name of the file in which to search for the specified string.
/? Displays help at the command prompt.


  • If you don't use /i, this command searches for exactly what you specify for string. For example, this command treats the characters a and A differently. If you use /i, however, the search becomes non-case-sensitive, and it treats a and A as the same character.

  • If the string you want to search for contains quotation marks, you must use double quotation marks for each quotation mark contained within the string (for example, ""This string contains quotation marks"").

  • If you omit a file name, this command acts as a filter, taking input from the standard input source (usually the keyboard, a pipe (|), or a redirected file) and then displays any lines that contain string.

  • You can type parameters and command-line options for the find command in any order.

  • You can't use wildcards (* and ?) in file names or extensions that you specify while using this command. To search for a string in a set of files that you specify with wildcards, you can use this command within a for command.

  • If you use /c and /v in the same command line, this command displays a count of the lines that don't contain the specified string. If you specify /c and /n in the same command line, find ignores /n.

  • This command doesn't recognize carriage returns. When you use this command to search for text in a file that includes carriage returns, you must limit the search string to text that can be found between carriage returns (that is, a string that is not likely to be interrupted by a carriage return). For example, this command doesn't report a match for the string tax file if a carriage return occurs between the words tax and file.


To display all lines from that contain the string pencil sharpener, type:

find pencil sharpener

To find the text, "The scientists labeled their paper for discussion only. It is not a final report." in the report.doc file, type:

find ""The scientists labeled their paper for discussion only. It is not a final report."" report.doc

To search for a set of files, you can use the find command within the for command. To search the current directory for files that have the extension .bat and that contain the string PROMPT, type:

for %f in (*.bat) do find PROMPT %f

To search your hard disk to find and display the file names on drive C that contain the string CPU, use the pipe (|) to direct the output of the dir command to the find command as follows:

dir c:\ /s /b | find CPU

Because find searches are case-sensitive and dir produces uppercase output, you must either type the string CPU in uppercase letters or use the /i command-line option with find.

Additional References