Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In MS Windows XP, in DOS, is it possible to do a content search(for a line or a word) in a file using command prompt.?

If so can we search a directory as well.? i.e it should search all the files in the directory for a specific word or phrase.


share|improve this question

migrated from Jun 18 '10 at 20:45

This question came from our site for professional and enthusiast programmers.

What platform and shell? – Nick Bastin Jun 17 '10 at 5:20

5 Answers 5

up vote 3 down vote accepted

There are two options: FIND or FINDSTR, both of which are built-in to the Windows Command Prompt.

You can use FIND to search for a simple string in a file:

FIND "apple" file.txt

You can also use it to search all files in the current directory:

FIND "apple" *

FINDSTR has a few more options: you can do searches with regular expressions, and you can search recursively into subdirectories:

FINDSTR /s "apple" *

In all cases, these commands print each line that matches the string to be searched, along with the file they were found in.

share|improve this answer

if you are looking for out of the box solution then you can use the fndstr command which comes with XP.

share|improve this answer


share|improve this answer

On unix the command is find, which takes a mini-language on the command line for defining what to find.

The short version of how to use it is:

$ find [where in the file tree to start]+ [how to filter files]+ [actions]+

and a common usage would be

$ find . ~ -name '*.mp3' -print

which means start in this directory (.) and my home directory (~), select only files with names ending in .mp3 (the -name filter), and print the path (using the -print action).

There are many more selection operators, and a modest set of actions. To do something complicated with the files you've found you either use -exec or print their names and pipe to xargs.

share|improve this answer

You can use DIR command to find out files.
Suppose you want to search for a file with name Example.txt

dir D:\ /s /b  find "Example.txt"

It takes hardly 10 seconds to search through the entire disc. If you want to search in another disc lets say E. Then change the text to E:\

You can also convert this command to a .vbs file so that you will not have to type the command manually each time. You can refer Search files with VB Script using command prompt

Update: Sorry for misunderstanding. The question was for searching contents in a file. My solution was for searching file names. Anyway, if anybody searching for file names using command prompt it might help.

share|improve this answer
OP asked for content search, not filename search. – gronostaj Jun 27 '13 at 18:51
Thanks gronostaj, for making me aware of it. It was a misunderstanding. I updated my statements. – Hari Das Jun 29 '13 at 15:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.