Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows command equivalent of egrep

Can I run this in a Windows command prompt like I can run it in UNIX?

egrep -wi 'FRIENDS|FOES' *.sql

This command is intended to scan each SQL file for the whole keywords "Friends" and "Foes," ignoring case.

like image 950
Oh Chin Boon Avatar asked Feb 02 '12 08:02

Oh Chin Boon


4 Answers

Well you can have cygwin on Windows so then you have bash, grep, etc.

If you need only grep, then there is GnuWin32.

If you don't want to install anything and is on Win XP, try findstr, although it can't do "orring".

If you are on Win-7, then there is powershell, with select-string.

like image 111
Zsolt Botykai Avatar answered Oct 27 '22 01:10

Zsolt Botykai


I think the findstr command is a fair enough substitute Windows command in place of Linux.

like image 29
Oh Chin Boon Avatar answered Oct 26 '22 23:10

Oh Chin Boon


The Windows equivalent would be the FIND command:

C:\>find /?
Searches for a text string in a file or files.

FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]]

  /V         Displays all lines NOT containing the specified string.
  /C         Displays only the count of lines containing the string.
  /N         Displays line numbers with the displayed lines.
  /I         Ignores the case of characters when searching for the string.
  /OFF[LINE] Do not skip files with offline attribute set.
  "string"   Specifies the text string to find.
  [drive:][path]filename
             Specifies a file or files to search.

If a path is not specified, FIND searches the text typed at the prompt
or piped from another command.

But you can also download most of the unix utilities (incl. grep) from http://gnuwin32.sourceforge.net/ (just drop them into your PATH and use them).

like image 3
a_horse_with_no_name Avatar answered Oct 26 '22 23:10

a_horse_with_no_name


Depends on your system. Do you have some version of grep installed? Windows has no equvalent of grep out of the box, but you can install Cygwin / GnuWin or unxutils.sourceforge.net.

like image 2
Mithrandir Avatar answered Oct 26 '22 23:10

Mithrandir