How to search a string in multiple files and return the names of files in Powershell?

后端 未结 11 1890
野的像风
野的像风 2020-11-30 15:57

I have started learning powershell a couple of days ago, and I couldn\'t find anything on google that does what I need so please bear with my question.

I have been a

11条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 16:34

    Pipe the content of your

    Get-ChildItem -recurse | Get-Content | Select-String -pattern "dummy"
    

    to fl *

    You will see that the path is already being returned as a property of the objects.

    IF you want just the path, use select path or select -unique path to remove duplicates:

    Get-ChildItem -recurse | Get-Content | Select-String -pattern "dummy" | select -unique path
    

提交回复
热议问题