PowerShell equivalent of LINQ Any()?

前端 未结 11 661
灰色年华
灰色年华 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:13

    I ended up doing it with a count:

    $directoryContainsSvn = {
        (Get-ChildItem $_.Name -force | ? {$_.PsIsContainer -and $_.Name -eq "_svn" -or $_.Name -eq ".svn"} | Measure-Object).Count -eq 1
    }
    $svnDirs = Get-ChildItem | ? {$_.PsIsContainer} | ? $directoryContainsSvn
    

提交回复
热议问题