Thursday, August 9, 2012

GREP in Windows

Few people know that Windows comes with its own search function to find text within files.

This is the FindStr command.

For example to search for the word localhost, one can use the command as such:

FINDSTR /SPIN "localhost" *.*

Where /S means search this current directory and all children recursively
/P skips files with non-printable characters
/I makes it case insensitive
/N shows the line number before every result.

One can then also pipe the output into an output file,

FINDSTR /SPIN "localhost" *.* > C:\Output.txt

This command can even take regular expressions as a search string

No comments: