sed -n如果没有输出,那么加上一个 -i会直接清空目标文件。
[root@study ~]# sed 's/#//' file1
a
b
c
d
e
f
[root@study ~]# sed 's/#//' file1 -n
[root@study ~]# sed 's/#//' file1 -n -i.bak
[root@study ~]# cat file1
#上面的命令没有输出,下面是file1的源文件内容
[root@study ~]# cat file1.bak
a
b
#c
d
e
f