1,使用sed命令去替换文本中的内容:
sed -i 就是直接对文本文件进行操作的
sed -i 's/原字符串/新字符串/' 文件名
sed -i 's/原字符串/新字符串/g' 文件名
sed -i "s/dd/ss/" file6
[yxx@localhost yxx_shell]$ cat file6
dd
dddd
fff
ff
[yxx@localhost yxx_shell]$ sed -i "s/dd/ss/" file6
[yxx@localhost yxx_shell]$ cat file6
ss
ssdd
fff
ff
[yxx@localhost yxx_shell]$
sed -i "s/dd/ss/g" file6
[yxx@localhost yxx_shell]$ cat file6
dd
dddd
fff
ff
[yxx@localhost yxx_shell]$ sed -i "s/dd/ss/g" file6
[yxx@localhost yxx_shell]$ cat file6
ss
ssss
fff
ff
[yxx@localhost yxx_shell]$