How to grep a word and nth line of that word recursively?



we have multiple files and directories, in that i need to grep Nth line of a word match and redirect that output to a new file.

Ex: i have a file called reports.html, in that i need to grep the word “Total” and 5th line of its value “67%” and send these to a new file.
Please help me in doing this.


assuming that my HTML file to be that way:

<!DOCTYPE html>
	<meta charset="utf-8" />
	<div id="app">

Try this:

grep -A 5 Total reports.html | awk ‘FNR == 6 { print substr($1, 6, length($1)-11) }’