title: Unix grep line above and concatenate
body: <p>here is my sample input from a log file.</p>
  
  <pre><code>#2014 03 06 11:21:44:028#+1300#
  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  [UserID= testUser]
  </code></pre>
  
  <p>What I am trying to do is go through all the log entries and do a grep command on the "UserID=" and then get the line 2 lines above (the timestamp). I then wish my output file to be a concatenation of the two into the file tempLog.txt</p>
  
  <pre><code> #2014 03 06 11:21:44:028#+1300# [UserID= testUser]
  </code></pre>
  
  <p>Can anyone help me with this? Still kinda new to Unix.... :)</p>
  
  <p>Thanks
  Chris</p>
  
  <p>UPDATED DUMMY DATA</p>
  
  <pre><code>#2.#2014 03 06 11:21:29:163#+1300#Info#/System/Security/Audit/Logon#
  #xxxxxx (Has white spaces)
  Logon failed    | LOGIN.ERROR   | null  |       | Login Method=[default], IP Address=[xx.xx.xxxx], UserID=[testUser], Reason=[Authentication did not succeed.]#
  </code></pre>