Expand inside a grep

par='one" -e "two'

I want to expand the variable (a little bit more complex) in a grep construction like this (obviously not working):

ls |grep -e "${par}"

i tried different methods with eval with no result

Is there any way to archive this?

Thx in advance mates!

Klashxx,
See if this would work for you:

par='one|two'
ls | egrep "$par"

You do it just for fun, right? :slight_smile:

$ par='one" -e "two'
$ ls|eval "grep -e \"$par\""
one
two

Both solutions work just fine! I appreciate your help.

Radoulov , it was 50% fun %50 job ... i guessed that eval would be involved .. xP

Thx you guys!