开发者

PowerShell: filter string list

开发者 https://www.devze.com 2022-12-20 13:27 出处:网络
This seems like a very basic thing to do, but I am new to PowerShell and can\'t figure this out or find an example online...

This seems like a very basic thing to do, but I am new to PowerShell and can't figure this out or find an example online...

I am trying to filter a list of strings. This list of strings is the result of a "svn list" command (Subversion list of repository files), like:

svn list -R PATHTOREPOSITORY

I have tried

svn list -R PATHTOREPOSITORY | where {$_ -like "stringtomatch"}

and this does n开发者_StackOverflowot work. How can I fix it?


You might consider using -match instead of -like. -Match is more powerful (regex based) and will work like you were initially expecting:

svn list -R PATHTOREPOSITORY | where {$_ -match 'stringtomatch'} 


Use:

svn list -R PATHTOREPOSITORY | where {$_ -like "*stringtomatch*"}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号