# 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 #