I need to replace a string between two lines. For example:
"aaa\nfoo\nfoo\naaa\nfoo\nbbb\nfoo\nbbb" ==> "aaa\nfoo\nfoo\naaa\nright\nbbb\nfoo\nbbb"
I want to use perl like following format but failed:
echo -e "aaa\nfoo\nfoo\naaa\nfoo\nbbb\nfoo\nbbb" | perl -pe "code here"
So is there a good way to deal with it?
Both perl and awk is ok.
Perl:
if you need to match a pattern multiline, you must change the record separator. the flags m and s can be useful too.
see also
Awk: