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*:"

其他回答

我还发现了在Windows 7及以上版本中使用类似GREP的功能的另一种方法,无需安装任何额外的应用程序,在旧系统上,您可以使用安装Powershell。

在Powershell中,用户可以使用Where-Object,它具有相当全面的功能集,提供了GREP的所有功能以及更多。

希望有帮助。

Cygwin grep和更多;)

如前所述,findstr工作得很好。例子:

C:>dir | findstr Windows

11/06/2013 09:55 PM Windows

PowerShell(在Windows 7/2008R2中作为标准包含,在XP/2003/Vista/2008中是可选的),它为此目的包含了select-string cmdlet。

如果您不介意付费产品,PowerGREP是我个人的最爱。