Here is the line of text:
SRC='999'
where 999 can be any three digits.
I need a grep command that will return me the 999. How do I do this?
Here is how to do it using sed
grep SRC=\'.*\' | sed 's/SRC=.\(.*\)./\1/'
                        You can use the -o option on grep to return only the part of the string that matches the regex:
echo "SRC='999'" | grep -o -E '[0-9]{3}'
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With