MS-DOS and Windows command line find command

Updated: 05/21/2018 by Computer Hope
find command

The find command allows you to search for text within a file. Although MS-DOS itself is not case-sensitive, when typing in the string that you are looking for with the find command, you'll need to make sure that you're using the correct case.

Additionally, this command is used to find text within a file, not the actual file itself. If you want to search or find a file with a particular name, use the dir command.

Tip

If you're running Windows XP or later, consider using the improved findstr command.

Availability

Find is an external command that is available for the following Microsoft operating systems as find.exe.

Find syntax

Windows Vista and later syntax

FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]file name[ ...]]

/V Displays all lines NOT containing the specified string.
/C Displays only the count of lines containing the string.
/N Displays line numbers with the displayed lines.
/I Ignores the case of characters when searching for the string.
/OFF[LINE] Do not skip files with offline attribute set.
"string" Specifies the text string to find.
[drive:][path]file name Specifies a file or files to search.

If a pathname is not specified, FIND searches the text typed at the prompt or piped from another command.

Windows XP and earlier syntax

FIND [/V] [/C] [/N] [/I] "string" [[drive:][path]file name[ ...]]

/V Displays all lines NOT containing the specified string.
/C Displays only the count of lines containing the string.
/N Displays line numbers with the displayed lines.
/I Ignores the case of characters when searching for the string.
"string" Specifies the text string to find.
[drive:][path]file name Specifies a file or files to search.

If a pathname is not specified, FIND searches the text typed at the prompt or piped from another command.

Find examples

find /c "REM" c:\autoexec.bat

The example above would find any "REM" statement in the autoexec.bat.

find /v /c "&*fake&*" programs.txt

List each line not containing "&*fake&*," because it's very unlikely that any file would containing this string of text this would give you an accurate line count of the file.

find "hope" *.txt

The next example searches for any text file (.txt) that contains the text hope in the current directory. As can be seen in the output below, the only file that contains hope is the CH.TXT file.

---------- ACTIVE SETUP LOG.TXT

---------- CH.TXT
computer hope

---------- MODEMDET.TXT

---------- OEWABLOG.TXT

---------- SCHEDLGU.TXT

---------- SETUPLOG.TXT

Additional information

  • See our find definition for further information and related links on this term.