Use awk to extract value from a line
Using sed
:
sed -E 's/.*limit"*>([0-9]+)<.*/\1/' file
Explanation:.*
takes care of everything that comes before the string limit
limit"*
takes care of both the lines, one with limit"
and the other one with just limit
([0-9]+)
takes care of matching numbers and only numbers as stated in your requirement.
\1
is actually a shortcut for capturing pattern. When a pattern groups all or part of its content into a pair of parentheses, it captures that content and stores it temporarily in memory. For more details, please refer https://www.inkling.com/read/introducing-regular-expressions-michael-fitzgerald-1st/chapter-4/capturing-groups-and