Aqui está uma maneira de usar GNU sed
:
sed -n '/--/,/Content-Length: 0/ { H; /Content-Length: 0/ { g; s/\n\(.*\)\n.*--.*//p } }'
Resultado:
line 1 "--"
line 2
line 3 "Content-Length: 20"
Explicação:
Match between the pattern range. Append this range to the hold space. On the last
line of the range, copy the hold space to pattern space to work with it. Then use
find/replace regex to remove everything after the last occurrence of '--'. HTH.