title: How can I extract first and last line from multiple text blocks separated with new line?
body: <p>I have a file containing multiple tests with detailed action written one beneath another. All test blocks are separated one from another by new line. I want to extract only first and last line from the all blocks and put it on one line for each block into a new file. Here is an example: </p>
  
  <p><strong>input.txt</strong>:</p>
  
  <pre><code>[test1]
  duration
  summary
  code=
  Results= PASS
  
  [test2]
  duration
  summary=x
  code=
  Results=FAIL
  
  .....
  
  [testX]
  duration
  summary=x
  code=
  Results= PASS
  </code></pre>
  
  <p><strong>output.txt</strong> should be sometime like this:</p>
  
  <pre><code>test1 PASS
  test2 FAIL
  ...
  testX PASS
  </code></pre>
  
  <p>eg2:</p>
  
  <pre><code>[Linux_MP3Enc_xffv.2_Con_37_003]
  type = testcase
  summary = MP3 encoder test
  ActionGroup[Linux_Enc] = PASS
  ActionGroup[Linux_Playb] = PASS
  ActionGroup[Linux_Pause_Resume] = PASS
  ActionGroup[Linux_Fast_Seek] = PASS
  Duration = 230.607398987 s
  Total_Result = PASS
  
  [Composer__vtx_007]
  type = testcase
  summary = composer
  Background[0xff000000] = PASS
  Background[0xffFFFFFF] = PASS
  Background[0xffFF0000] = PASS
  Background[0xff00FF00] = PASS
  Background[0xff0000FF] = PASS
  Background[0xff00FFFF] = PASS
  Background[0xffFFFF00] = PASS
  Background[0xffFF00FF] = PASS
  Duration = 28.3567230701 s
  Total_Result = PASS
  
  
  [Videox_Rotate_008]
  type = testcase
  summary = rotation
  Rotation[0] = PASS
  Rotation[1] = PASS
  Rotation[2] = PASS
  Rotation[3] = PASS
  Duration = 14.0116529465 s
  Total_Result = PASS
  </code></pre>
  
  <p>Thank you!</p>