Windows命令提示符中是否有与grep类似的实用程序,或者是否有第三方工具?


当前回答

我知道这是一个老问题,但我看到这个帖子寻求答案。我找到了一个,所以把它添加到这里,作为互联网的集体记忆

Powershell:选择string 模块: Microsoft.PowerShell.Utility

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/select-string

以及一篇包含高级示例的内容丰富的博客文章:“如何在PowerShell中“grep”” https://antjanus.com/blog/web-development-tutorials/how-to-grep-in-powershell/

举个简单的例子: 猫包。选择字符串-模式webpack . json | ls ./src/components/ | Select-String -Pattern View

C:>猫帖。md | Select-String -Pattern "^\w*:"

其他回答

Grep for Windows by GnuWin Project(2014-10-02:它已经过时了,见下面的评论)

我知道这是一个老问题,但我看到这个帖子寻求答案。我找到了一个,所以把它添加到这里,作为互联网的集体记忆

Powershell:选择string 模块: Microsoft.PowerShell.Utility

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/select-string

以及一篇包含高级示例的内容丰富的博客文章:“如何在PowerShell中“grep”” https://antjanus.com/blog/web-development-tutorials/how-to-grep-in-powershell/

举个简单的例子: 猫包。选择字符串-模式webpack . json | ls ./src/components/ | Select-String -Pattern View

C:>猫帖。md | Select-String -Pattern "^\w*:"

所有Windows nt类操作系统都有一个名为FINDSTR的命令行工具(FINDSTR /?它不支持grep所做的一切,但它可能足以满足您的需求。

Yes there is only one program for Windows PC which have solid GUI and it is essential util for me. I work as a developer and on every computer I've had, first thing install XFind program. It is created in 1997 and till now version is 1.0 and till now works and it is the best. Frequently I need to search some string in a ".cs", ".aspx", ".sct" (Visual FoxPro form code file) or just ".*" and XFind scans all files and show me files and another great thing is that you can look where string is in the file. XFind has also some kind of editor. If it binary file it will show you string finded. Try it and use it forever if you are developer like me.

如果你想要一个GUI, Bare Grep是不错的选择。Gnu grep适合CLI