Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想word用\word{sth}sed替换。我输入
word
\word{sth}
sed -i s@word@\\word{sth}
但我得到的是 word{sth} 而不是 \word{sth}
我也在命令中尝试了 1 个斜杠
您应该添加四个反斜杠。
你需要两个来逃避终端的反斜杠,两个来逃避它的sed。2*2=4。
$ echo word|sed s@word@\\\\word{sth}@gi \word{sth}
考虑sed用单引号括起来表达式'
sed
'
sed -i 's@word@\\word{sth}@' file