sed命令作为一个强大的shell命令,可以快速删除任意特定的行列,配合awk命令可以轻松地操作批量处理文件,下面就来看看吧!
sed命令常用到的两个选项:
-i : 直接在文件上编辑 (edit files in place)
-e[默认选项]:只在命令行输出,而文件不改变(add the script to the commands to be executed)
注:使用sed命令可以使用 -i 或者 -e 选项(以下例子仅以-i举例)
sed命令删除特定行号
删除第N行
sed -i 'Nd' filename
删除第N~M行
sed -i 'N,Md' filen