我正在尝试在文件中的"rezhome"之前添加一行,如下所示:
...
app3-reservation,
app4-reservation,
app5-reservation,
rezhome
当我使用以下命令在本地运行时,它工作正常。
sed -i 's/rezhome/app5-reservation, \n&/' grouphost.cfg
但是使用 ssh 反斜杠无法转义,我得到以下结果
ssh localhost "sed -i 's/rezhome/app5-reservation, \n&/' /path/grouphost.cfg"
...
app3-reservation,
app4-reservation,
app5-reservation, nrezhome
请帮忙吗?
由sed
和ssh
处理,因此您需要进一步转义它们才能将其与两者一起使用。 尝试:
ssh localhost "sed -i 's/rezhome/app5-reservation, \\n&/' /path/grouphost.cfg"