PowerShell equivalent to grep -f

前端 未结 9 1676
情书的邮戳
情书的邮戳 2020-12-22 16:09

I\'m looking for the PowerShell equivalent to grep --file=filename. If you don\'t know grep, filename is a text file where each line has a regular

9条回答
  •  没有蜡笔的小新
    2020-12-22 16:20

    I'm not familiar with grep but with Select-String you can do:

    Get-ChildItem filename.txt | Select-String -Pattern 
    

    You can also do that with Get-Content:

    (Get-Content filename.txt) -match 'pattern'
    

提交回复
热议问题