2

i writing small script in Powershell and i have no idea for another steps...

I have array with:

$666 = "abrakadabra","blabla/blabla","blabla/abraka_dabra(20_10_2015).bla"

In file saved on HDD, i have file, named as content.txt. In this file i need find string from array. With "abrakadabra" and "blabla/blabla" i dont have problems, but with "blabla/abraka_dabra(20_10_2015).bla" yes.

As part of script i triing this with:

foreach ( $line in $666 ) { select-string content.txt -pattern $line }

Thanks for any help

1
  • Select-String -Path content.txt -Pattern $666 -SimpleMatch Commented Nov 19, 2015 at 10:21

1 Answer 1

2

You just have to escape the special chars from your patterns, here is an easy way:

$666 |% {select-string content.txt -pattern ([RegEx]::Escape($_)) }

Sign up to request clarification or add additional context in comments.

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.