Find files which does not contains selected string

前端 未结 3 1332
独厮守ぢ
独厮守ぢ 2021-02-04 05:25

I am trying to find all files, which does not contains a selected string. Find files which contains is easy:

gci | select-string \"something\"

3条回答
  •  感情败类
    2021-02-04 06:09

    I'm not sure if it can be done without the foreach-object but this works:

    gci |foreach-object{if (-not (select-string -inputobject $_ -Pattern "something")){$_}}
    

提交回复
热议问题