在文本文件中,我想使用perl在另一行文本的每个匹配之前插入一行新文本.
示例 - 我的文件是:
holiday
april
icecream: sunday
jujubee
carefree
icecream: sunday
Christmas
icecream: sunday
towel
...
Run Code Online (Sandbox Code Playgroud)
我想'icecream: saturday'在' icecream: sunday'行之前插入一行文本.所以之后,文本文件看起来像.是的,我需要结肠:在搜索和替换模式中都.
holiday
april
icecream: saturday
icecream: sunday
jujubee
carefree
icecream: saturday
icecream: sunday
Christmas
icecream: saturday
icecream: sunday
towel
...
Run Code Online (Sandbox Code Playgroud)
我想在Windows PC上使用perl 5.14来做这件事.我已经安装了Perl.我在这个网站上搜索并尝试了很多其他的例子,但它们并不适合我,不幸的是我不是Perl的完整专家.
如果有一个例子也使用sed我也有Cygwin sed.