title: Shell script/regex: extraction across multiple lines
body: <p>I'm trying to write a log parsing script to extract failed events. I can pull these with grep:</p>
  
  <pre><code>$ grep -A5 "FAILED" log.txt
  
  2008-08-19 17:50:07 [7052] [14] DEBUG:      data: 3a 46 41 49 4c 45 44 20 20 65 72 72 3a 30 32 33   :FAILED  err:023
  2008-08-19 17:50:07 [7052] [14] DEBUG:      data: 20 74 65 78 74 3a 20 00                            text: .
  2008-08-19 17:50:07 [7052] [14] DEBUG:    Octet string dump ends.
  2008-08-19 17:50:07 [7052] [14] DEBUG: SMPP PDU dump ends.
  2008-08-19 17:50:07 [7052] [14] DEBUG: SMPP[test] handle_pdu, got DLR
  2008-08-19 17:50:07 [7052] [14] DEBUG: DLR[internal]: Looking for DLR smsc=test, ts=1158667543, dst=447872123456, type=2
  --
  2008-08-19 17:50:07 [7052] [8] DEBUG:      data: 3a 46 41 49 4c 45 44 20 20 65 72 72 3a 30 32 34   :FAILED  err:024
  2008-08-19 17:50:07 [7052] [8] DEBUG:      data: 20 74 65 78 74 3a 20 00                            text: .
  2008-08-19 17:50:07 [7052] [8] DEBUG:    Octet string dump ends.
  2008-08-19 17:50:07 [7052] [8] DEBUG: SMPP PDU dump ends.
  2008-08-19 17:50:07 [7052] [8] DEBUG: SMPP[test] handle_pdu, got DLR
  2008-08-19 17:50:07 [7052] [8] DEBUG: DLR[internal]: Looking for DLR smsc=test, ts=1040097716, dst=447872987654, type=2
  </code></pre>
  
  <p>What I'm interested in is, for each block, the error code (i.e. the "023" part of ":FAILED err:023" on the first line) and the dst number (i.e."447872123456" from "dst=447872123456" on the last line.)</p>
  
  <p>Can anyone help with a shell one-liner to extract those two values, or provide some hints as to how I should approach this?</p>