Is there a Pattern Matching Utility like GREP in Windows?

前端 未结 30 1098
不知归路
不知归路 2020-12-04 06:23

Is there a similar utility to grep available from the Windows Command Prompt, or is there a third party tool for it?

30条回答
  •  青春惊慌失措
    2020-12-04 06:59

    I realize its an old question but I came across this post seeking an answer. And I have found one so adding it here for the collective internet memory

    Powershell: Select-String Module: Microsoft.PowerShell.Utility

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

    and an informative blog post with advanced examnples: "How to “grep” in PowerShell" https://antjanus.com/blog/web-development-tutorials/how-to-grep-in-powershell/

    A simple example from that blog post: cat package.json | Select-String -Pattern webpack ls ./src/components/ | Select-String -Pattern View

    C:> cat post.md | Select-String -Pattern "^\w*:"

提交回复
热议问题