Could you post an actual sample containing both cases. It is hard to test an answer without test data. Sometimes a description of the problem isn't enough. I'm not certain whether there is more than one line of textafter "Summary"; whether there is always a blank line before "Summary"; or whether there are blank lines elsewhere. Be sure to post the last summary record. Whether there is a blank line after the last summary could determine whether a "/Summary:/,/^$/" range will match for the last summary.
You shouldn't have joined the lines in the example barbea posted.
Code:
cat summaryexample
Summary:
This is a non blank line right after the Summary heading.
This is a part of the summary.
Summary:
There is a blank line after the summary.
The last line of the file is blank.
Code:
sed -n '/^Summary/!p
/^Summary/ {N
s/\n$//
p}' summaryexample |
sed -n '/^Summary/,/^$/p'
Summary:
This is a non blank line right after the Summary heading.
This is a part of the summary.
Summary:
There is a blank line after the summary.
The last line of the file is blank.
It is important to use proper indentation so that the structure of the sed program stands out. That way you can see easily which commands are executed only in a range or subrange.