14

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. How can I fix it?

2 Answers 2

27

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'} 
Sign up to request clarification or add additional context in comments.

Comments

11

Use:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.