I would like to grep digits inside a set of parentheses after a match.
Given foo.txt
below,
foo: "32.1" bar: "42.0" misc: "52.3"
I want to extract the number after bar, 42.0
.
The following line will match, but I'd like to extract the digit. I guess I could pipe the output back into grep looking for \d+.\d+
, but is there a better way?
grep -o -P 'bar: "\d+.\d+"' foo.txt