PowerShell equivalent of LINQ Any()?

前端 未结 11 675
灰色年华
灰色年华 2020-12-01 03:29

I would like to find all directories at the top level from the location of the script that are stored in subversion.

In C# it would be something like this

         


        
11条回答
  •  死守一世寂寞
    2020-12-01 04:15

    You can tighten this up a bit:

    gci -fo | ?{$_.PSIsContainer -and `
                (gci $_ -r -fo | ?{$_.PSIsContainer -and $_ -match '[_.]svn$'})}
    

    Note - passing $__.Name to the nested gci is unnecessary. Passing it $_ is sufficent.

提交回复
热议问题