Ray*_*yes 317
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
Run Code Online (Sandbox Code Playgroud)
用法示例:findstr text_to_find *或以递归方式搜索findstr /s text_to_find *
Mar*_*iek 198
(我仍然是PowerGREP的粉丝,但我不再使用它了.)
我知道你已经提到过了,但是PowerGREP 太棒了.
我最喜欢的一些功能是:
现在我意识到其他grep工具可以完成上述所有工作.只是PowerGREP将所有功能打包成一个非常易于使用的GUI.
来自同样精彩的人们给你带来了RegexBuddy以及我与他们没有任何关系而超越了他们的东西.(应该注意的是,RegexBuddy包含grep的基本版本(适用于Windows)本身,它的成本远低于PowerGREP.)
小智 106
GrepWin免费开源(GPL)
我一直在使用grepWin,这是由一个tortoisesvn家伙写的.Windows上的工作是......
http://stefanstools.sourceforge.net/grepWin.html
Von*_*onC 52
2013年7月更新:
我现在在Windows上一直使用的另一个grep工具是AstroGrep:

它能够向我展示的不仅仅是行搜索(即--context =命令行grep的NUM)是非常宝贵的.
它很快.非常快,即使在使用非SSD驱动器的旧计算机上(我知道,他们曾经使用旋转磁盘做这个硬盘,称为盘片,疯狂吧?)
这是免费的.
它是便携式的(解压缩的简单zip存档).
原始答案2008年10月
Gnu Grep没事
你可以在这里下载它:( 站点ftp)
所有常见的选择都在这里.
结合gawk和xargs(包括'find',来自GnuWin32),你可以像在Unix上一样编写脚本!
grep --include "*.xxx" -nRHI "my Text to grep" *
Run Code Online (Sandbox Code Playgroud)
Jay*_*uzi 30
PowerShell的Select-String cmdlet在v1.0中运行良好,但对于v2.0则明显更好.将PowerShell内置到最新版本的Windows中意味着您的技能始终有用,无需先安装.
添加到Select-String的新参数:Select-String cmdlet现在支持新参数,例如:
- -Context:这允许您查看匹配行之前和之后的行
- -AllMatches:允许您查看一行中的所有匹配项(以前,您只能看到一行中的第一个匹配项)
- -NotMatch:相当于grep -vo
- -Encoding:指定字符编码
我觉得适宜创建一个功能gcir为Get-ChildItem -Recurse .,以智慧来正确地传递参数,以及别名ss为Select-String.所以你写一下:
gcir*.txt | ss foo
jas*_*ray 23
它可能不完全属于'grep'类别,但如果没有名为AgentRansack的实用程序,我无法在Windows上使用它.它是一个基于gui的"在文件中查找"实用程序,具有正则表达式支持.右键单击文件夹,点击"搜索..."并查找包含您要查找的内容的文件非常简单.非常快.
jj.*_*jj. 17
你问这个问题已经有几年了,但我推荐AstroGrep(http://astrogrep.sourceforge.net).
它是免费的,开源的,并且具有简单的界面.我一直用它来搜索代码.
jsl*_*tts 16
PowerShell已被提及几次.以下是如何以实际的方式使用它:
Get-ChildItem -recurse -include *.txt | Select-String -CaseSensitive "SomeString"
Run Code Online (Sandbox Code Playgroud)
它递归搜索当前目录树中的所有文本文件SomeString以区分大小写.
更好的是,运行这个:
function pgrep { param([string]$search, [string]$inc) Get-ChildItem -recurse -include $inc | Select-String -CaseSensitive $search }
Run Code Online (Sandbox Code Playgroud)
然后做:
pgrep SomeStringToSearch *.txt
Run Code Online (Sandbox Code Playgroud)
然后要真正使它变得神奇,将功能别名添加到PowerShell配置文件中,您几乎可以消除没有正确命令行工具的痛苦.
Dan*_*son 13
Git on Windows = grep in cmd.exe
我刚刚发现安装Git会给你一些基本的Linux命令:cat,grep,scp和所有其他好的命令.
安装然后将Git bin文件夹添加到PATH,然后您的cmd.exe具有基本的Linux功能!
http://code.google.com/p/msysgit/downloads/list?can=3
那么,在GNU grep的Windows端口旁边:
http://gnuwin32.sourceforge.net/
Borland的免费C++编译器(它是一个带命令行工具的免费软件)中也有Borland的grep(非常类似于GNU).
小智 6
我是Aba Search and Replace的作者.就像PowerGREP一样,它支持正则表达式,保存模式以供进一步使用,撤消替换,使用HTML/CSS/JS/PHP的语法高亮预览,不同的编码,包括UTF-8和UTF-16.
与PowerGREP相比,GUI 不那么混乱.当您输入模式(增量搜索)时, Aba立即开始搜索,因此您可以尝试使用正则表达式并立即查看结果.
欢迎您试用我的工具; 我很乐意回答任何问题.