title: grep -A|grep -o
body: <p>Hey I am trying to output the exact matching expressions that I want (and there are a series of them in an HTML page). For that in order to be able to get rid of the rubbish I need to use grep -A and then from this result match the expression that I want. However, it doe not work. What I am expecting after </p>
  
  <pre><code>curl -s https://somewebsite.com|grep A- 2 '&lt;h3 class="title"&gt;'|grep -o '&lt;a href="[a-zA-Z0-9./]+"&gt;'
  </code></pre>
  
  <p>I would expect to get:</p>
  
  <p>only something like</p>
  
  <pre><code>&lt;a href="/blah/blah/9/blah."&gt;
  </code></pre>
  
  <p>but instead, I get everything back as if I did not have the second grep at all.</p>
  
  <pre><code>&lt;h3 class="title"&gt;
  &lt;a href="/blah/blah/9/blah."&gt;
  &lt;/h3&gt;
  </code></pre>
  
  <p>Could you guys help me with the problem?</p>
  
  <p>Here is an edit which might help you guys to help me.
  If I do the following:</p>
  
  <pre><code>curl -s https://somewebsite.com|grep A- 2 '&lt;h3 class="title"&gt;' &gt;&gt; test.txt
  grep -o '&lt;a href="[a-zA-Z0-9./]+"&gt;' test.txt
  </code></pre>
  
  <p>everything works just fine.</p>