Q:

sed over ssh doesn't escape backslash

I'm trying to add a line before "rezhome" in the file as it would look like below:
...
app3-reservation, \
app4-reservation, \
app5-reservation, \
rezhome

When I run locally with below command it works fine.
sed -i 's/rezhome/app5-reservation, \\\n&/' grouphost.cfg

But using ssh backslash is not escaped and I get below result
ssh localhost "sed -i 's/rezhome/app5-reservation, \\\n&/' /path/grouphost.cfg"

...
app3-reservation, \
app4-reservation, \
app5-reservation, \nrezhome

Any help please?

A:

The \ gets processed by both the sed and the ssh so you'll need to further escape them to use it with both.  Try:
 ssh localhost "sed -i 's/rezhome/app5-reservation, \\\\\n&/' /path/grouphost.cfg"

