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

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

I have a text (.txt) file located somewhere on my PC that contains a bunch of data, including the following string:

Secret Username: ********* 
Secret Password: *********

How can I find this file from command-line, using Findstr?
I don't know if it's on C: drive or D: drive.

I tried various Findstr queries, such as:

findstr /s /m /n /i Secret Username C:
findstr /s /m /n /i Secret Username D:
findstr /s /m /n /i /c:"Secret Username"
findstr /s /m /n /r /i .*Secret Username.*

but couldn't find the file.

share|improve this question
up vote 3 down vote accepted
findstr /S /M /I /C:"Secret Username" C:\*.txt
share|improve this answer
It finds hundreds of files (lots of Java files), but there's no way they contain this string. Is it because it doesn't look for the whole string? – amiregelz Nov 18 '12 at 16:32
so sorry, there was a mistake, I did an Edit ... – bummi Nov 18 '12 at 16:54
Do you know if it starts searching from where cmd.exe is located or from the path showed in command-line itself (for me it's C:\Users\amiregelz)? – amiregelz Nov 18 '12 at 17:05
that's why it ends with C:*.*, you have credentials? – bummi Nov 18 '12 at 17:08
The /N switch already limits the output to the matching line. Furthermore, the command handles about 1 GB a minute. There's a very rough estimate, but scanning the entire C:-drive typically takes a few hours as opposed to five minutes. You can limit the search to .txt-files for a significant performance boost. I have edited the answer accordingly. – Marcks Thomas Nov 18 '12 at 18:05

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.