tags:

views:

57

answers:

2

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 not work...anyone know this?

+2  A: 

This always happens. I spend hours trying to figure out the solution, post the question on StackOverflow, and then immediately answer my own question...sorry...

The answer is:

svn list -R PATHTOREPOSITORY | where {$_ -like "*stringtomatch*"}
Mike Gates
+4  A: 

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'} 
Keith Hill
Much better...thanks!
Mike Gates