title: Swap with a consecutive line on a pattern match in unix
body: <p>Can any one help me in sorting this out in sed/awk/perl</p>
  
  <p>Input file</p>
  
  <pre><code>Start variable 1
  End   variable 2
  A
  Z
  Next 
  
  Start variable b
  End   variable a 
  X
  Y
  Next 
  ...
  ...
  ...
  
  Start variable m
  End   variable n
  M
  N
  Next
  </code></pre>
  
  <p>If a pattern match  <code>End</code> found, swap with its consecutive line</p>
  
  <p>Output file :</p>
  
  <pre><code>Start variable 1
  A
  End variable 2 
  Z
  Next
  
  Start variable b
  X
  End variable a
  Y
  Next
  ...
  ...
  ...
  
  Start variable m
  M
  End variable n
  N
  Next
  </code></pre>