[转] Shell 文本替换命令

可以这样做:
方法1:在原文件中修改
sed -i 's/被替换的内容/要替换成的内容/' file

方法2:
sed 's/被替换的内容/要替换成的内容/g' file > file.out
mv file.out file

这里注意:
不能这样做:
sed 's/被替换的内容/要替换成的内容/g' file > file
这样只会清空源文件。

猜你喜欢

转载自superabbits.iteye.com/blog/1137128