sed常用命令

删除匹配行

删除包含test的行
sed -i '/test/d' etc/test

替换匹配行

替换hehe为haha
sed -i 's/hehe/haha/g' tmp.txt

在指定行添加

在第二行添加haha,最后的\n是换行符
sed -i "2 a haha\n"

你可能感兴趣的:(sed常用命令)