SED help wanted

Could any SED expert help out with this small problem?

I have a short SED script which works using a file sedscr:
Code:
s/^/echo '/
s/$/' >>fubar/
which works fine with
sed -f sedscr temp
I'm trying to execute this as a single command:-
sed -e "s/^/echo '/" -e "s/$/' >>fubar/" temp

but can't get it to work. The first part works, but the second part gives me an error
Code:
Illegal variable name.
The '$' is supposed to match the end of the line but seems to be getting misinterpreted.

Can anyone explain what I need to do/
 
The '$' is supposed to match the end of the line but seems to be getting misinterpreted.
You need to escape it. It's because it's within a double quoted (") string which causes the shell to interpret $ as the start of a variable name (and $/ is obviously an illegal variable name).
 
Back
Top