关于Windows的grep工具有什么建议吗?理想情况下,可以利用64位操作系统。

当然,我知道Cygwin,也发现了PowerGREP,但我想知道是否有任何隐藏的宝石在那里?


当前回答

Windows上的Git = cmd.exe中的grep

我刚刚发现安装Git会给你一些基本的Linux命令:cat、grep、scp和所有其他好的命令。

安装,然后将Git bin文件夹添加到您的PATH,然后您的cmd.exe具有基本的Linux功能!

http://code.google.com/p/msysgit/downloads/list?can=3

其他回答

FINDSTR相当强大,支持正则表达式,并且具有在所有Windows机器上都可以运行的优点。

c:\> 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 occurances 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

用法示例:findstr text_to_find *或递归搜索findstr /s text_to_find *

我是《阿坝搜索与替代》一书的作者。就像PowerGREP一样,它支持正则表达式、保存模式以供将来使用、撤销替换、HTML/CSS/JS/PHP的语法高亮预览、不同的编码,包括UTF-8和UTF-16。

与PowerGREP相比,GUI不那么杂乱。当您键入模式时,Aba立即开始搜索(增量搜索),因此您可以尝试使用正则表达式并立即看到结果。

欢迎您试用我的工具;我很乐意回答任何问题。

它可能不完全属于“grep”类别,但如果没有一个名为AgentRansack的实用程序,我就无法在Windows上使用它。它是一个基于gui的“在文件中查找”实用程序,支持正则表达式。

右键单击一个文件夹,点击“ransack..”,就能找到你要找的文件。它的速度也非常快。

我推荐AstroGrep。

它是免费的,开源的,并且有一个简单的界面。我一直用它来搜索代码。

PowerShell的Select-String类似。它没有相同的选项和语义,但仍然很强大。