Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Grep for Windows

Posted on 2013-01-03
4
Medium Priority
?
689 Views
Last Modified: 2013-11-15
I need a copy of 'grep' for Windows.   Preferrably a good old command line version with regular expressions.  Don't want to install CygWin, Perl, or anything else.

I downloaded and installed Windows Grep from wingrep.com but it only seems to display the filename and line number.  I need to extract matching lines to another text file.

Thank you in advance.

AielloJ
0
Comment
Question by:AielloJ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 39

Assisted Solution

by:Aaron Tomosky
Aaron Tomosky earned 600 total points
ID: 38742884
What about mobaxterm? Nothing to install
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 800 total points
ID: 38743036
The GnuWin32 utilities includes 'grep'.
http://sourceforge.net/projects/gnuwin32/files/?source=navbar
0
 
LVL 35

Assisted Solution

by:Ernie Beek
Ernie Beek earned 600 total points
ID: 38743284
Or just get the grep:
http://gnuwin32.sourceforge.net/packages/grep.htm

You can also try findstr which is already in windows:

 findstr /?
Searches for strings in files.

FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file]
        [/C:string] [/G:file] [/D:dir list] [/A:color attributes] [/OFF[LINE]]
        strings [[drive:][path]filename[ ...]]

  /B         Matches pattern if at the beginning of a line.
  /E         Matches pattern if at the end of a line.
  /L         Uses search strings literally.
  /R         Uses search strings as regular expressions.
  /S         Searches for matching files in the current directory and all
             subdirectories.
  /I         Specifies that the search is not to be case-sensitive.
  /X         Prints lines that match exactly.
  /V         Prints only lines that do not contain a match.
  /N         Prints the line number before each line that matches.
  /M         Prints only the filename if a file contains a match.
  /O         Prints character offset before each matching line.
  /P         Skip files with non-printable characters.
  /OFF[LINE] Do not skip files with offline attribute set.
  /A:attr    Specifies color attribute with two hex digits. See "color /?"
  /F:file    Reads file list from the specified file(/ stands for console).
  /C:string  Uses specified string as a literal search string.
  /G:file    Gets search strings from the specified file(/ stands for console).
  /D:dir     Search a semicolon delimited list of directories
  strings    Text to be searched for.
  [drive:][path]filename
             Specifies a file or files to search.

Use spaces to separate multiple search strings unless the argument is prefixed
with /C.  For example, 'FINDSTR "hello there" x.y' searches for "hello" or
"there" in file x.y.  'FINDSTR /C:"hello there" x.y' searches for
"hello there" in file x.y.

Regular expression quick reference:
  .        Wildcard: any character
  *        Repeat: zero or more occurrences of previous character or class
  ^        Line position: beginning of line
  $        Line position: end of line
  [class]  Character class: any one character in set
  [^class] Inverse class: any one character not in set
  [x-y]    Range: any characters within the specified range
  \x       Escape: literal use of metacharacter x
  \<xyz    Word position: beginning of word
  xyz\>    Word position: end of word

For full information on FINDSTR regular expressions refer to the online Command
Reference.

Open in new window

0
 
LVL 13

Author Comment

by:AielloJ
ID: 38743432
Thanks you for the replies!  I tried FINDSTR but it didn't seem to work with the regular expressions.  I need to extract "<MarkJ 1>" and "<MarkJ 2>" from all the files in a folder and subfolder and redirect the output to another file.  It didn't seem to like search strings with spaces as parameters.  I used "<MarkJ 1>\|<MarkJ 2>"

I'll look at the other greps.

Best regards,
AielloJ
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Invest in your employees with these five simple steps to improve employee engagement and retention.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
This video will demonstrate how to find the puppet warp tool from the edit menu and where to put the points to edit.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This videā€¦

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question