I want to achieve the same as explained in sed: Extract version number from string, but taking into consideration only the first sequence of numbers or even safer, tell sed to keep only the sequence of numbers following the name of the command, leaving out the rest.
I have:
Chromium 12.0.742.112 Ubuntu 11.04
I want:
12.0.742.112
Instead of:
12.0.742.11211.04
I now know that using head or tail with sort it is possible to display the largest/smallest number, but how can I tell sed to consider the first sequence only?
EDIT: I forgot to mention that I'm using bash.
The first number? How about:
sed 's/[^0-9.]*\([0-9.]*\).*/\1/'
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