1

Kindly suggest how can I search a text string which will be input by the user in all files of a directory.

Thanks in advance!!

3 Answers3

3

findstr is your friend.

For example, to find all files containing Hello:

findstr Hello *

It also allows subdirectory searches (/s) and regular expressions (/r) as well.

Of course, you can't achieve real power unless you install and use the Cygwin or GnuWin32 tools. Cygwin if you want an entire UNIX-like environment or GnuWin32 if you just want select tools.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • PowerShell! At least nicer than Cygwin, imho :-) – Joey Oct 15 '09 at 19:52
  • Powershell, bah! :-) I already know all the UNIX tools and quite a bit of cmd.exe (where absolutely necessary). I don't want to have to learn yet another tool until it becomes unworkable doing it with Cygwin. – paxdiablo Oct 16 '09 at 07:42
1

Just use grep. On Windows download GNU grep or other free available grep.

Michał Niklas
  • 53,067
  • 18
  • 70
  • 114
0

Are you looking for FINDSTR ? I am assuming your using windows.

Andrew Keith
  • 7,515
  • 1
  • 25
  • 41