Grep command in shell script

Hi,

I have written the following shell script -

Error_String="error"
var1="| grep -v note1 | grep -v note2"
grep -i $Error_String /users/mqm/Pwork/Err/*.out $var1

The above script gives error saying "grep: can't open |
grep: can't open grep
grep: can't open -v" etc

In my program note1 and note2 strings are dynamically generated, so I cannot hardcode those in grep command.

Could anyone please help me to resolve this problem

Thanks in advance,
Prasanna

Maybe you'll need something like this:

$ cat test
this
is
a
node1
test
node2

$ var="node1|node2"

$ grep -Ev $var test
this
is
a
test

Cabrao's regex solution is better than using pipeline.

If you want to use your own script replace the " with `