Windows

Use Windows Server 2003's qgrep utility to find information

Get a grep -- a qgrep, that is. The qgrep utility in the Windows Server 2003 Resource Kit can help you find lines specific to an expression, allowing you to get information on the files you want.

For many years, UNIX and Linux administrators have enjoyed the power of grep. In UNIX-land, grep means "search globally for lines matching the expression and print the lines." The Windows Server 2003 Resource Kit includes a utility called qgrep that brings this functionality to Windows Server 2003.

To use qgrep, install the Windows Server 2003 Resource Kit, change to the Tools directory and execute qgrep. The output below gives you a look at all of the options available with qgrep.exe.

C:\Program Files (x86)\Windows Resource Kits\Tools|qgrep /?

usage: qgrep [-?BELOXlnzvxy][-e string][-f file][-i file][strings][files]

  • -?: print this message
  • -B: match pattern if at beginning of line
  • -E: match pattern if at end of line
  • -L: treat search strings literally (fgrep)
  • -O: print seek offset before each matching line
  • -X: treat search strings as regular expressions (grep)
  • -l: print only file name if file contains match
  • -n: print line number before each matching line
  • -z: print matching lines in MSC error message format
  • -v: print only lines not containing a match
  • -x: print lines that match exactly (-BE)
  • -y: treat upper and lower case as equivalent
  • -e: treat next argument literally as a search string
  • -f: read search strings from file named by next argument (- = stdin)
  • -i: read file list from file named by next argument (- = stdin)

White space separates search strings unless the argument has a prefix of -e (for example, 'qgrep "all out" x.y' means find either "all" or "out" in x.y, while 'qgrep -e "all out" x.y' means find "all out."

Here is an example that shows you how to use qgrep. In this case, the example looks for the word Windows in all of the text files in the directory.

C:\Program Files (x86)\Windows Resource Kits\Tools|qgrep Windows *.txt

pooltag.txt:IBCM - wibcm.sys - CM_INSTANCE_TAG Windows Infiniband Communications Manager

pooltag.txt:IBm* - wibms.sys - Windows Infiniband Management Server pool tags

pooltag.txt:IbPm - wibpm.sys - WIBPM_TAG Windows Infiniband Performance Manager

pooltag.txt:IbW0 - wibwmi.sys - WIBWMI0_TAG Windows Infiniband WMI Manager

Miss a column?

Check out the Windows Server 2003 archive, and catch up on the most recent tips from this newsletter.

Stay on top of the latest WS2K3 tips and tricks with our free Windows Server 2003 newsletter, delivered each Wednesday. Automatically sign up today!

5 comments
rschiller
rschiller

Certainly much more successful than windows search - but is there a way to recurse through the directory structure?

Carl Hall
Carl Hall

qgrep is also available for windows XP.

halibut
halibut

It has been around since windows 2000 resource kit actually.

DanLM
DanLM

This should be a counter suit. I wonder how many other utilities that MS couldn't think of for them selves they have stolen from the open source area. Sorry, just that law suite irks me. Dan

rkuhn040172
rkuhn040172

Both sides have probably stolen more ideas from the other than all of us could ever possibly imagine.

Editor's Picks