Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Windows (http://www.go4expert.com/articles/windows/)
-   -   *nix grep-like Power with qgrep on Windows 2003 Server (http://www.go4expert.com/articles/nix-grep-power-qgrep-windows-2003-server-t8131/)

pradeep 6Jan2008 23:55

*nix grep-like Power with qgrep on Windows 2003 Server
 
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.

Code:

C:\Program Files\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.

Code:

C:\Program Files\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


Nadr 10Jan2008 21:57

Re: *nix grep-like Power with qgrep on Windows 2003 Server
 
Nice one.


All times are GMT +5.5. The time now is 02:07.