I have this in a file:
<tr class="LightRow Center" style="height:auto;">
<td class="SmallText resultbadB" title="Non-Compliant/Vulnerable/Unpatched" style="width:20%">0</td>
<td class="SmallText resultgoodB" title="Compliant/Non-Vulnerable/Patched" style="width:20%">1</td>
<td class="SmallText errorB" title="Error" style="width:20%">0</td>
<td class="SmallText unknownB" title="Unknown" style="width:20%">0</td>
<td class="SmallText otherB" title="Inventory/Miscellaneous class, or Not Applicable/Not Evaluated result" style="width:20%">0</td>
</tr>
</table>
I am trying to get at the text from this row:
<td class="SmallText resultbadB" title="Non-Compliant/Vulnerable/Unpatched" style="width:20%">0</td>
This is being done a shell script and I am trying to use the bash regular expressions.
I have tried this shell script
#!/bin/bash
set -x
REGEX_EXPR='\<td\ class=\"SmallText\ resultbadB\"\ title=\"Non-Compliant\/Vulnerable\/Unpatched\"\ style=\"width\:20\%\"\>\(.*\)\</td\>'
[[ /tmp/result.html =~ $REGEX_EXPR ]]
echo "output $?"
echo ${BASH_REMATCH[0]}
echo ${BASH_REMATCH[1]}
However I get a no match response (1) on the echo "output $?"
I have tried the following regex's as well.
REGEX_EXPR='<td class="SmallText resultbadB" title="Non-Compliant/Vulnerable/Unpatched" style="width:20%">\(.*\)</td>'
REGEX_EXPR='<td class="SmallText resultbadB" title="Non-Compliant/Vulnerable/Unpatched" style="width:20%">(.*)</td>'
And some other escape combinations, example, escaped just the quotes. Tried to define the variable in quotes and so on.
Any thoughts on where I am messing up?
'