tags:

views:

174

answers:

3

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!!

+1  A: 

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

Michał Niklas
A: 

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

Andrew Keith
+2  A: 

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
PowerShell! At least nicer than Cygwin, imho :-)
Joey
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