With GNU grep, you can use -m 1 to exit after the first match. e.g.
grep -m 1 '<td class="headerCovTableEntryLo">' index.html
From man grep:
-m NUM, --max-count=NUM
Stop reading a file after NUM matching lines. If the
input is standard input from a regular file, and NUM
matching lines are output, grep ensures that the standard
input is positioned to just after the last matching line
before exiting, regardless of the presence of trailing
context lines. This enables a calling process to resume
a search.
When grep stops after NUM matching lines, it outputs any
trailing context lines.
When the -c or --countoption is also used, grep does not output a count greater than NUM. When the-vor--invert-match` option is also used, grep stops after
outputting NUM non-matching lines.
To then extract just the value, pipe it into sed. e.g.
$ grep -m 1 '<td class="headerCovTableEntryLo">' index.html |
sed -e 's/^[^>]*>//; s/ %.*//'
39.2
Or, forget about grep and do the whole thing in sed:
$ sed -ne '/<td class="headerCovTableEntryLo">/ {s/^[^>]*>//; s/ %.*//p;q}' index.html
39.2
You really ought to use a HTML parser, though. Using regular expressions alone on structured data like HTML, XML, JSON, etc is doomed to failure.
<td class="headerCovTableEntryLo">39.2 %</td>or just39.2?grep?