我正在寻找最佳方法来查找文件中的特定文本,并从Linux命令行中围绕其中包含其他文本。查找文件中的特定文本并用其他文本换行
因此,例如,该文件可能包含以下内容:
This
is
a
test.
anchor-start
text to wrap will is in here
anchor-end
所以在上面的例子中,我想找到anchor-start
和anchor-end
之间,然后将文本,这样我结束了换行文字:
This
is
a
test.
anchor-start
wrapping-start
text to wrap will is in here
wrapping-end
anchor-end
我也应该注意到,我要寻找一个解决方案,由此,如果anchor-start
后面紧跟wrapping-start
(已经发生,即包装),那么它不应该被重复。
看看SED与'锚启动\ nwrapping-start'和''用包装锚end'取代'锚start' -end \ nanchor-end' – scibuff 2012-02-26 20:17:54
排除双重包装,你可以使用负面的环视[例如,在Perl](http://ideone.com/Gyfpl)。 – jfs 2012-02-26 22:00:12