关于Windows的grep工具有什么建议吗?理想情况下,可以利用64位操作系统。
当然,我知道Cygwin,也发现了PowerGREP,但我想知道是否有任何隐藏的宝石在那里?
关于Windows的grep工具有什么建议吗?理想情况下,可以利用64位操作系统。
当然,我知道Cygwin,也发现了PowerGREP,但我想知道是否有任何隐藏的宝石在那里?
当前回答
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 *
其他回答
我已经成功地使用了一段时间的Win32 GNU实用程序,它有一个很好的grep,以及tail和其他方便的Win32 GNU实用程序。我避免使用打包的shell,而是直接在Win32命令提示符中使用可执行文件。
被包装的尾巴也是一个很好的小应用。
我想要一个免费的Windows grep工具,允许你右键单击一个文件夹,并对每个文件进行正则表达式搜索-没有任何唠叨屏幕。
下面是一个基于前一篇文章中提到的findstr的快速解决方案。
在硬盘上的某个地方创建一个文本文件,用于保存长寿命工具。重命名为.bat或.cmd,并将以下文件粘贴进去:
@echo off
set /p term="Search term> "
del %temp%\grepresult.txt
findstr /i /S /R /n /C:"%term%" "%~1\*.*" > "%temp%\grepresult.txt"
start notepad "%temp%\grepresult.txt"
然后浏览到SendTo文件夹。在Windows 7上浏览到%APPDATA%\Microsoft\Windows\SendTo并将批处理文件的快捷方式拖到该SendTo文件夹中。
我将快捷方式重命名为1 GREP,以使其保持在SendTo列表的顶部。
我接下来要做的事情是将findstr的输出通过生成html文件的东西输送,这样您就可以单击每个输出行来打开该文件。而且,我不认为它在文件夹的快捷方式上起作用。我必须检查参数,看看它是否包含“.lnk”。
如果你想要一个简单易用的Windows Grep工具,我创建了一个叫做P-Grep的工具,可以从我的网站上免费下载:www.adjutantit.com -主菜单,下载。
Windows Grep在处理大量文件时似乎存在问题,所以我自己编写了一个似乎更可靠的程序。您可以选择一个文件夹,右键单击并发送到P-Grep。sendto文件夹在安装期间更新。
PowerShell的Select-String类似。它没有相同的选项和语义,但仍然很强大。
dnGREP是一个开源的Windows grep工具。它支持许多很酷的功能,包括:
撤销替换 能力搜索右键单击文件夹在资源管理器 高级搜索选项,如语音搜索和xpath 在PDF文件、档案和Word文档中搜索
恕我直言,它也有一个漂亮干净的界面:)