Dos Command Search Within File

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.

Replace Text in Plain Text Files from the Command Line Jason Faulkner August 30, 2010, 6:00am EDT A very useful function which is missing from the Windows library of command line tools is the ability to replace text in plain text files. From the Start menu, choose All Programs→Accessories→Command Prompt. Type CD and press Enter. That’s CD, a space, and then the backslash character. This command propels you to the root directory (folder) on the main hard drive. Type DIR and a space. Type the name of the file you’re looking for.

DOS Search Command-line techies can use the DOS command from 30 years ago. Add the /s option to search the directories recursively. Windows 8 Method Searches There are two Windows 8 method search options. Press Windows key + W for this search dialogue box. The screen shows file names that match what you entered. Find files based on modified time. But we do have a command to search for files based on the file modification time. To work for dates modified within # of.

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.
/CDisplays only the count of lines containing the string.
/N Displays line numbers with the displayed lines.
/IIgnores 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[ ..]]

Dos Search Files For Text

/V Displays all lines NOT containing the specified string.
/CDisplays only the count of lines containing the string.
/N Displays line numbers with the displayed lines.
/IIgnores 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.
Dos

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

Find examples

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

Series

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.

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.

Ms Dos Find Command

---------- ACTIVE SETUP LOG.TXT
---------- CH.TXT
computer hope
---------- MODEMDET.TXT
---------- OEWABLOG.TXT
---------- SCHEDLGU.TXT
---------- SETUPLOG.TXT Fiat ecu scan keygen crack idm.

All Dos Commands With Example

Additional information

Dos Command Search File Contents

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