【发布时间】:2017-12-17 08:10:58
【问题描述】:
如何使用sed 在匹配%%### 模式的每一行的开头和结尾添加\n?这是我走了多远:
如果foo.txt 包含
foobar
%%## Foo
%%### Bar
foobar
然后sed 's/^%%###/\n&\n/g' foo.txt 给出
foobar
%%## Foo
%%###
Bar
foobar
而不是
foobar
%%## Foo
%%### Bar
foobar
注意:这似乎与this post有关
更新:我实际上是在寻找仅考虑以模式开始的行的情况。
【问题讨论】: