I would want to only remove the lines between PATTERN1(aaa) and PATTERN2(ccc), excluding the others lines where the patterns matches.
I trying to delete the empty line between PATTERN1(aaa) and PATTERN2(ccc), line 8 in my example...This line will be no all times in same location, that is the reason, why I try to remove it using the 2 patterns.
Essentially it boils down to: "If a blank line is found between aaa and ccc then remove it..
I am glad if it was useful, @jiam912
The code has grown a bit, but I could not find another way to get around the buffer size limit
sed -r ':1;N;/a[^\n]*\n*$/b1;l;s/(^a.*$)\n+(^c.*$)/\1\n\2/m'
The problem was as follows.
If the string starting with 'a' was even line then the code did not work properly.
Add the 'l' command to look at the contents of the buffer (the line marked at the end with a dollar sign)
and add one line to the input file.