Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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 must log in to answer this question.

protected by Community Dec 1 '15 at 23:12

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged .