Issue with SED command

I have a file that contains lines like this:

allgroups: cn=Role1,cn=groups,o=xyz,st=mn,c=us
allgroups: cn=Role1,cn=groups,o=xyz,st=mn,c=us

I want to remove the string :

,cn=groups,o=xyz,st=mn,c=us

and so I tried to use SED. i tried to assign it to a variable and use it:

sRemStr1=",cn=groups,o=xyz,st=mn,c=us"
sed 's/$sRemStr1//g' ${sTmpPrefix}.Orig  > ${sTmpPrefix}.txt

But it doesnt work. It works only when I give like this:

sed 's/,cn=groups,o=xyz,st=mn,c=us//g' ${sTmpPrefix}.Orig  > ${sTmpPrefix}.txt

Not sure what is the problem. Pls help.

Kumar

You have to use double quotes instead

Problem is not with sed. Problem is with your shell. Variable substitution occurs in the shell and the result is then fed to the command you want to run; so, you need to allow the shell to do variable substitution in order for the command to work. Single quotes inhibit variable substitution, but double quotes allow it. In conclusion, as sol_nov accurately says, use double quotes.

Thank you guys for the tip. It works.