awk to match pattern in html and use regex : <p>Using <code>awk</code> to parse an <code>html</code> and it does execute but prints the entire line not just the percentage as in the desired. My thinking is that the pattern <code>reads passed filters:</code> is matched, then the <code>regex</code> is used to use the <code>&lt;/td&gt;&lt;td class='col2'&gt;78.760142 M</code> and print the field after. There are aditional lines above and below, but the are different then the pattern. Thank you :).</p>

<p>file</p>

<pre><code>...
...
&lt;tr&gt;&lt;td class='col1'&gt;reads passed filters:&lt;/td&gt;&lt;td class='col2'&gt;78.760142 M (95.514721%)&lt;/td&gt;&lt;/tr&gt;
...
...
</code></pre>

<p>awk</p>

<pre><code>awk -F'reads passed filters:[^a-z][0-9][::space::][a-z][::space::]*' '/reads passed filters:/ {sub("[^a-z][0-9][::space::][a-z][::space::].*", "", $1); print $1}' file
</code></pre>

<p>current</p>

<pre><code>&lt;tr&gt;&lt;td class='col1'&gt;reads passed filters:&lt;/td&gt;&lt;td class='col2'&gt;78.760142 M (95.514721%)&lt;/td&gt;&lt;/tr&gt;
</code></pre>

<p>desired</p>

<pre><code>95.514721%
</code></pre>
