Windows command equivalent to egrep

Can I run this on a windows command prompt, how can I run it on UNIX?

egrep -wi 'FRIENDS|FOES' *.sql 

This command is designed to scan each SQL file for all the keywords "Friends" and "Enemies", ignoring the case.

+6
source share
6 answers

I think the findstr command is a fairly suitable replacement for the Windows command instead of Linux.

+3
source

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

If you only need grep, then GnuWin32 .

If you do not want to install anything and use Win XP, try findstr , although it cannot do "orring".

If you are on Win-7, that is powershell , select-string .

+5
source

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

+2
source

the Windows equivalent is 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 unix utilities (including grep) from http://gnuwin32.sourceforge.net/ (just put them in your PATH and use them).

+2
source

I'm not sure about the state of OR, but the main function should look like

 type *.sql | find /n "FRIENDS" 
+2
source

Here is the egrep equivalent of "string1 | string2 | string3":

PS: C:> findstr / C: string1 / C: string2 / C: string3

0
source

Source: https://habr.com/ru/post/907466/


All Articles