Windows 中是否有像 GREP 这样的模式匹配实用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1416241/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a Pattern Matching Utility like GREP in Windows?
提问by Chintan Shah
Is there a similar utility to grep
available from the Windows Command Prompt, or is there a third party tool for it?
是否有grep
可从 Windows 命令提示符使用的类似实用程序,或者是否有第三方工具?
采纳答案by Chintan Shah
I also found one more way of utilizing GREP like functionality in Windows 7 and above without any extra application to install and on older systems you can use install Powershell.
我还发现了另一种在 Windows 7 及更高版本中使用类似 GREP 功能的方法,无需安装任何额外的应用程序,在较旧的系统上,您可以使用安装 Powershell。
In Powershell, User can use Where-Objectit has quite comprehensive set of feature that provides all the functionality of GREP plus more.
在Powershell 中,用户可以使用Where-Object它具有相当全面的功能集,可提供 GREP 的所有功能以及更多功能。
Hope It helps.
希望能帮助到你。
回答by Ken Keenan
There is a command-line tool called FINDSTR
that comes with all Windows NT-class operating systems (type FINDSTR /?
into a Command Prompt window for more information) It doesn't support everything grep
does but it might be sufficient for your needs.
FINDSTR
所有 Windows NT 类操作系统都有一个名为的命令行工具(FINDSTR /?
在命令提示符窗口中键入以获取更多信息)它不支持所有grep
功能,但它可能足以满足您的需求。
回答by Richard
PowerShell (included as standard on Windows 7/2008R2, optional for XP/2003/Vista/2008) which includes the select-string
cmdlet for this purpose.
PowerShell(包含在 Windows 7/2008R2 上的标准配置,XP/2003/Vista/2008 可选),其中包含select-string
用于此目的的cmdlet。
回答by Gregor
Grep for Windows by GnuWin Project(2014-10-02: It's outdated, see comments below)
GnuWin 项目的 Windows 版 Grep(2014 年 10 月 2 日:已过时,请参阅下面的评论)
回答by Parallel Universe
as mentioned, findstr works fine. example :
如前所述, findstr 工作正常。例子 :
C:>dir | findstr Windows
C:>目录 | findstr 视窗
11/06/2013 09:55 PM Windows
11/06/2013 下午 09:55
回答by Svend
I'm surprised no one has mentioned FINDSTR. I'm no grep poweruser, but findstr does what I need it to, filter files and stdin, with some primitive regex support. Ships with Windows and all that. (Edit: Well someone did mention findstr, It's late I guess)
我很惊讶没有人提到FINDSTR。我不是 grep poweruser,但 findstr 做我需要的事情,过滤文件和标准输入,并提供一些原始的正则表达式支持。随 Windows 和所有这些一起提供。(编辑:嗯,有人提到了 findstr,我猜是晚了)
回答by Diaa Sami
GnuWin32is worth mentioning, it provides native Win32 version of all standard linux tools, including grep, file, sed, groff, indent, etc.
GnuWin32值得一提,它提供了所有标准 linux 工具的原生 Win32 版本,包括 grep、file、sed、groff、indent 等。
And it's constantly updated when new versions of these tools are released.
当这些工具的新版本发布时,它会不断更新。
回答by anatoly techtonik
On Windows I use Far Managerfor file search. BSD licensed, works in console, saves time on typing cmdline parameters. Here is its search dialog invoked by Alt-F7.
在 Windows 上,我使用Far Manager进行文件搜索。BSD 许可,在控制台中工作,节省输入 cmdline 参数的时间。这是 Alt-F7 调用的搜索对话框。
回答by woodvi
Update: This wasn't true when the question was originally asked, but now Microsoft lets one Install the Windows Subsystem for Linux, and Windows will then run grep. In PowerShell, run:
更新:最初提出这个问题时,情况并非如此,但现在微软允许安装 Windows Subsystem for Linux,然后 Windows 将运行 grep。在 PowerShell 中,运行:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux