FindStr.exe an egrep-like tool
I've long thought of writing a little tool like grep (or egrep) which would allow me to quickly use regex to search for text within files. This weekend while reading an article about Standard I/O and Console Applications I discovered the Windows command-line tool FindStr.
FindStr.exe is a command-line tool which searches for patterns of text in files using regular expressions. Let's say I've got a folder full of documents and I want to search through and find any instance of the pattern "WebService" I can fire up a Command Prompt, change the path to my where my folder is and use FindStr.exe to perform the search:
cd c:\MyFolder findstr /s /i WebService *.*
This displays a list of all lines in all files in which the search term was found. Another neat trick is that you can use the greater than operator - ">" - to redirect the results to a text file, like so:
cd c:\MyFolder findstr /s /i WebService *.* >Results.txt
This redirects all results to a file named Results.txt. So there it is, an egrep-like utility already which is already baked into Windows OS - I never knew that!
Cross posted on http://weblogs.asp.net/DNeimke and http://blogs.regexadvice.com/DNeimke