sed替换文本
$ cat demo.txt my name is <name>. # Linux $ sed -i 's/<name>/Tom/' demo.txt # Mac终端,-i 指令后多加一个 "" $ sed -i '' 's/<name>/Tom/' demo.txt $ cat demo.txt my name is Tom.
遇到的问题:
Mac下执行sed -i
会有错误提示
sed: 1: "demo.txt": extra characters at the end of d command • 1
参考
踩坑sed :1:extra characters at the end of t command
Mac终端需要在 -i
指令后多加一个 ""