Solved

Grep for Windows

Posted on 2013-01-03
4
634 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
4 Comments
 
LVL 38

Assisted Solution

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

Accepted Solution

by:
Dave Baldwin earned 200 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 150 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
This video demonstrates basic masking and how to edit the mask to reveal the desired image.
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.

744 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now