Use awk to extract value from a line Use awk to extract value from a line bash bash

Use awk to extract value from a line


awk -F'[<>]' '{print $3}' input.txt

input.txt:

<first-value system-property="unique.setting.limit">3</first-value><second-value-limit>50000</second-value-limit>

Output:

350000


        sed -e 's/[a-zA-Z.<\/>= \-]//g' file


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