Reputation: 21
I have this string Time: 4 days (361440 seconds)
and trying to extract only the number 361440 from this. I have gotten so far as to extract 361440 seconds
using sed "s/.*(\(.*\))/\1/"
I keep going round in circles trying to just get the number from it.
Thanks
Upvotes: 0
Views: 52
Reputation: 195029
You didn't explain the rule of extraction very clearly. Just based on your sed codes, this grep line should work for your example:
grep -oP '\(\K\d+'
Ok, then extend your sed one-liner a bit:
sed 's/.*(\([0-9]\+\).*/\1/'
Upvotes: 1