Build Your Skills: Search through files quickly with Windows Grep

Use Grep to search files quickly in Microsoft Windows

As a longtime IT trainer, I’ve developed a large collection of course materials, which I routinely refer to when developing new materials for my latest class. But searching for a particular test or exercise using the Windows Find command can be as difficult as searching through paper files.

I longed for the grep command that I used in my UNIX days. Grep made it easy to search for files that contained a specific text string so that I would be able to specify a word or phrase, like “file save” or “cut and paste,” and find a document on that topic. Then, I came across a program called Windows Grep.

Windows Grep is a text-search utility that works like the UNIX/Linux grep utility but runs on Windows machines. With Windows Grep, you can search for text strings in binary files, such as word processor documents, databases, spreadsheets, and executables, and you can use it to search for and replace specific text strings in ASCII text files, such as program source, HTML, RTF, and batch files.

I Grep…You Grep…
As support pros, we're always trying to find innovative ways to help our end users and ourselves work more efficiently. Windows Grep can do just that when it comes to finding text strings. Perhaps you're searching for a specific directory reference in those batch files you created last year or you're helping an end user find a particular company name from a list of 20 Excel spreadsheets. Post a comment to this article and tell us how you use Windows Grep or a similar tool to make your job a little easier.

Searching with Windows Grep
You don't need to know anything about the UNIX grep utility to begin searching with Windows Grep. Windows Grep opens to a Search Assistant wizard that guides beginners through their first search. To demonstrate the Search Assistant, I will use it to search for all course materials on my Zip disk that pertain to spell checking.

Figure A

Figure A shows the first screen of the Search Assistant where you enter the text string; in this case, I entered spell. The wizard also allows you to indicate how you want the string to be searched, such as Find Whole Words Only, Soundex, etc. In this example, I performed a Normal (Regular Expression) search.

After clicking Next, you'll see the screen shown in Figure B, where you navigate to the drive you want to search and click the Right Arrow button to move it to the Includebox.

Figure B

After clicking Next, you'll see the screen shown in Figure C. Since I knew that the course material I was looking for was created in Microsoft Word, I selected the *.doc file type and clicked the Right Arrow button.

Figure C

To display the search results (Figure D), click the Finish button.

Figure D

Note that the Windows Grep search results screen is divided into two sections. The upper section lists the files that were found. Clicking on an individual file in the list displays the line(s) where the text string occurs (Figure E).

Figure E

Right-clicking a file in the list displays a menu with a number of options (Figure F). For example, when you select Edit <name of file>, the file will open in the default text editor. When you select Launch Associated Application, the file will open in the proper application, in this case, Microsoft Word. This makes it convenient for me to access the files I need, since almost immediately after Windows Grep finds the file, I can begin working with it.

Figure F

Using Windows Grep in Expert Mode
While working in Beginner Mode is useful, Expert Mode provides us with the full functionality of the UNIX grep. To switch to Expert Mode, select it from the Options menu, as shown in Figure G.

Figure G

Then, when the Search menu or Search button is clicked, the Search Criteria dialog box will be displayed.

Figure H

Expert Mode’s Search Criteria dialog box provides additional search options. For example, it allows zipped files to be searched; that is, it will first search for any files of the type specified (e.g., *.doc) in a zipped file and, if those files are found, extract them to a temporary folder and search for the string in the extracted files. The Text File Format Tab allows you to specify a delimited or fixed-length format that will enable delimited or fixed-width lists to be searched at an individual field level. Filters can be set via the Filters tab so that only those files that fall within a certain date/time or size range will be searched. As in Figure H, I used the Search Criteria dialog box to search for course materials on “Goal Seek.” The results ofthis search are shown in Figure I.

Figure I

Where to get Windows Grep
Windows Grep is a shareware program that you can download from the Windows Grep Web page. After downloading it, you can install the program within minutes. Windows Grep is provided at no charge for a 30-day trial period. A single user license fee is $30. Site licenses are also available.

Editor's Picks