shell 编辑文件——添加

来源:互联网 发布:dos命令查看mac地址 编辑:程序博客网 时间:2024/06/05 11:47

在文档中添加一行:

在指定行前面添加

sed -i '/2/i\here' test.txt

这里写图片描述

在指定行后面添加

sed -i '/2/a\after the line' test.txt

这里写图片描述

在最后面添加

sed -i '$a\last line' test.txt

这里写图片描述

原创粉丝点击