Raw Input Desired Output
 
Paragraph-1 Line 1
........... Line 2
........... Line 3
Paragraph-2 Line 1 ........... Line 2 PAT ........... Line 3
Paragraph-3 Line 1 ........... Line 2
 
Paragraph-1 Line 1
........... Line 2
........... Line 3
Paragraph-3 Line 1 ........... Line 2
Script and Comments
Script1
[ 1] /^$/b
[ 2] :loop
[ 3] $!{
[ 4] N
[ 5] /\n$/!b loop
[ 6] }
[ 7] /PAT/d
Comments
  1. `Pattern Space' is abbreviated to 'PS'.
  2. Step [1] prints every empty line except the first one following a paragraph, then starts a new cycle.
  3. Steps [2] thru [5] constitute a loop which append every following line to the end of PS until a separating empty line is read.
  4. In Step [7], there is exactly one paragraph in PS:
    • If it contains PAT, command `d'' empties PS and start a new cycle.
    • Otherwise, since the end of the script is reached, sed prints the contents of PS (the paragraph in question and the separating empty line), then start a new cycle.