sed

来源:互联网 发布:js微信通讯录字母索引 编辑:程序博客网 时间:2024/06/05 04:21

sed在首次匹配前插入:

一:sed $'0,/a/ {/a/ i c\n}' file

二:sed '/a/ {i c\n; :loop; n; b loop}'  file

Note: The a,i,c commands terminate on newlines, so you have to physically break the line in order to finish up the expression.

处理最后一次匹配情况时,可以使用tac先反转文件

0 0