title: how to print a section of file between two regular expressions only if a line within the section contains a certain string within it
body: <p>I have a file of events that has multiple multi lined events between <code>&lt;event&gt;</code> and <code>&lt;/event&gt;</code> tags. I want to print out the entire event From <code>&lt;event&gt;</code> to <code>&lt;/event&gt;</code> only if a line within that event contains either the string uniqueId="1279939300.862594_PFM_1_1912320699" or uniqueId="1281686522.353435_PFM_1_988171542". The file has 100000 events in it and each event has between 20 and 35 lines (attributes within the event vary its length). I started off using sed but need a little help beyond:</p>
  
  <pre><code>cat xmlEventLog_2010-03-23T* | sed -nr "/&lt;event eventTimestamp/,/&lt;\/event&gt;/"
  </code></pre>
  
  <p>What do I need to do to finish this? Also is sed the best way of doing this given the size of the files?</p>
  
  <p>Thanks in advance</p>
  
  <p>A</p>
  
  <p>I wanted to edit this to update. For certain reasons I want to do this with sed. I tried Denis's solution but it does not seem to work:</p>
  
  <pre><code>bash$ grep 1279939300.862594_PFM_1_1912320699 xmlEventLog*
  xmlEventLog_2010-03-23T02:41:15_PFM_1_1.xml:    &lt;event eventTimestamp="2010-03-23T02:41:40.861" originalReceivedMessageSize="0" uniqueId="1279939300.862594_PFM_1_1912320699"&gt;
  bash$ grep 1281686522.353435_PFM_1_988171542 xmlEventLog*
  xmlEventLog_2010-03-23T07:47:38_PFM_1_1.xml:    &lt;event eventTimestamp="2010-03-23T08:02:02.299" originalReceivedMessageSize="685" uniqueId="1281686522.353435_PFM_1_988171542"&gt;
  bash$ time sed -n ':a; /&lt;event&gt;/,/&lt;\/event&gt;/ N; /&lt;event&gt;/,/&lt;\/event&gt;/!b; /&lt;\/event&gt;/ {/uniqueId="1279939300.862594_PFM_1_1912320699"\|uniqueId="1281686522.353435_PFM_1_988171542"/p;d}; ba' xmlEventLog*
  
  real    1m13.134s
  user    1m12.463s
  sys     0m0.659s
  bash$
  </code></pre>
  
  <p>Which obviously returned nothing. So is it possible to do this with sed?</p>
  
  <p>A</p>