Windows命令相当于egrep

时间:2012-02-02 08:20:03

标签: windows command

我可以在Windows命令提示符下运行它,就像我可以在UNIX中运行它一样吗?

egrep -wi 'FRIENDS|FOES' *.sql

此命令用于扫描每个SQL文件中的整个关键字“Friends”和“Foes”,忽略大小写。

6 个答案:

答案 0 :(得分:5)

您可以在Windows上拥有cygwin,然后您拥有bashgrep等。

如果你只需要grep,那么就有GnuWin32

如果您不想安装任何东西并且在Win XP上,请尝试findstr,尽管它无法“orring”。

如果您使用的是Win-7,那么powershellselect-string

答案 1 :(得分:3)

我认为findstr命令是替代Linux的公平替代Windows命令。

答案 2 :(得分:2)

取决于您的系统。你有安装某个版本的grep吗? Windows没有开箱即用的grep等价物,但您可以安装Cygwin / GnuWin或unxutils.sourceforge.net

答案 3 :(得分:2)

Windows等价物将是FIND命令:

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.

但您也可以从http://gnuwin32.sourceforge.net/下载大部分unix实用程序(包括grep)(只需将它们放入PATH并使用它们)。

答案 4 :(得分:2)

我不确定OR条件,但基本功能看起来应该是

type *.sql | find /n "FRIENDS"

答案 5 :(得分:0)

这相当于egrep" string1 | string2 | string3":

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

相关问题