in reply to one liner append line(s) to matched paragraph
Here's one way to do it with a regexp:
# cat 1139933.dat para1 foo bar para1 some stuff para2 other stuff para2 foo bar para2 extra stuff para3 this is enough #
# perl -Mstrict -wne' $/ = ""; s/^(para2.*)^$/$1new text\n/ms; print; ' 1139933.dat para1 foo bar para1 some stuff para2 other stuff para2 foo bar new text para2 extra stuff new text para3 this is enough #
Update: new solution; hippo beat me to my first idea
|
---|