标题: 使用sed匹配某行,并新增一行,内容为。。。 [打印本页] 作者: johnson0418 时间: 2016-01-02 20:55 标题: 使用sed匹配某行,并新增一行,内容为。。。 [root ]$ cat quote.txt
The honeysuckle band played all night long for only $90.
It was an evening of splendid music and company.
Too bad the disco floor fell through at 23:00.
The local nurse Miss P.Neave was in attendance.
找到company这行,并新加一行内容为“Then suddenly it happed.”,但使用了下面的命令提示错误。(另外sed 无-i的参数)
sed "/company/a\Then suddenly it happened." quote.txt
sed: -e expression #1, char 11: Extra characters after command作者: baby_神 时间: 2016-01-03 00:18
[root@07 ~]# cat c
The honeysuckle band played all night long for only $90.
It was an evening of splendid music and company.
Too bad the disco floor fell through at 23:00.
The local nurse Miss P.Neave was in attendance.
[root@07 ~]# sed "/company/a\Then suddenly it happened." c
The honeysuckle band played all night long for only $90.
It was an evening of splendid music and company.
Then suddenly it happened.
Too bad the disco floor fell through at 23:00.
The local nurse Miss P.Neave was in attendance.
复制代码
[root@07 ~]# sed --version
GNU sed version 4.1.5
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,