sed -i 直接修改文件,无需输出
cat /tmp/t.txt
0.0.0.0
DROP
sed -i '/DROP/i test' /tmp/t.txt # 在指定行插入一行
cat /tmp/t.txt
0.0.0.0
test
DROP
sed -i '/^DROP/d' /tmp/t.txt # 删除指定的行
cat /tmp/t.txt
0.0.0.0
test
sed -i 's/0.0.0.0/127.0.0.1/g' /tmp/t.txt # 替换指定内容
cat /tmp/t.txt
127.0.0.1
test