1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

*nix grep-like Power with qgrep on Windows 2003 Server

Discussion in 'Windows' started by pradeep, Jan 6, 2008.

  1. pradeep

    pradeep Team Leader

    Apr 4, 2005
    Likes Received:
    Trophy Points:
    Kolkata, India
    Home Page:
    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\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\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
  2. Nadr

    Nadr New Member

    Oct 16, 2007
    Likes Received:
    Trophy Points:
    Nice one.

Share This Page