Case 1
We take into account two cases based on different requirements.

The first case is examining every line of a file. If a line contains 'PAT', then print the next line.

Raw Input Desired Output
Line 1
 This line contains PAT
Line 3
Line 4
 PAT is here
 One more line contains PAT
 Two more line contains PAT 
Line 8
 This has PAT, too
Line 10
Line 3
 One more line contains PAT
 Two more line contains PAT 
Line 8
Line 10
Script and Comments
Script1
[ 1] :loop
[ 2] $!N
[ 3] /PAT.*\n/!D
[ 4] s/^.*\n//p
[ 5] b loop
Comments
  1. Step [2] joins the next line to Pattern Space if the current line is not the last one of a file.
  2. After Step [2], Pattern Space will contain two lines:
    • If the first(current) line does not contain 'PAT', command 'D' will delete it but keep the second, then branch to Step [1].
    • Otherwise, Step [4] will delete the first line but keep the second(next) one. Since the substitution will be performed successfully, the option 'p' of command 's' will print the line after substitution. Step [5] will make sed branch to Step [1] then [2].
  3. An equivalent version is shown as follows.
Script2
[ 1] $!N
[ 2] /PAT.*\n/!D
[ 3] s/^.*\n\(.*\)/\1\n\1/
[ 4] P
[ 5] D
Case 2
A line will be printed if it does not contain 'PAT' and is preceded by an adjacent line containing 'PAT'.
Raw Input Desired Output
Line 1
 This line contains PAT
Line 3
Line 4
 PAT is here
 One more line contains PAT
 Two more line contains PAT 
Line 8
 This has PAT, too
Line 10
Line 3
Line 8
Line 10
Script and Comments
Script1
[ 1] /PAT/!d
[ 2] $!N
[ 3] /\n.*PAT/D
[ 4] s/^.*\n//
Comments
  1. Step [1] will discard a line if it does not contain 'PAT' (a qualified line will be joined via Step [2]).
  2. If the current line contains 'PAT', Step [2] will join the next line to Pattern Space.
  3. After Step [2], there will be two lines in Pattern Space. If the second(next) line contains 'PAT', command 'D' will delete the first one but keep the second, then branch to Step [1].
  4. Otherwise, Step [5] will delete the first but keep the second. Since the end of script is reached, sed will print it and start a new cycle.