Find command
The find command lets you search for text within a file. Although MS-DOS is not case-sensitive, when typing in the string, you'll need to make sure you're using the correct case.
Additionally, this command is used to find text in a file, not the actual file itself. To search or find a file with a particular name, use the dir command.
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.
- All Versions of MS-DOS
- Windows 95
- Windows 98
- Windows Me
- Windows NT
- Windows 2000
- Windows XP
- Windows Vista
- Windows 7
- Windows 8
- Windows 10
- Windows 11
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) containing the text hope in the current directory. As seen in the output below, the only file containing "hope" is the CH.TXT file.
---------- ACTIVE SETUP LOG.TXT
---------- CH.TXT
computer hope
---------- MODEMDET.TXT
---------- OEWABLOG.TXT
---------- SCHEDLGU.TXT
---------- SETUPLOG.TXT