If I have a string as follows: DATABASE PATCH FOR EORQ (JAN2014 - 11.2.0.4.1)
How would I go about matching the version number? I.e. I would like to extract 11.2.0.4.1
. I would like to avoid using sed and awk, as the line is arbitrary, and may change in the future, so I am looking for something which would match a version word containing digits as well as .
's.
I tried to use egrep as follows: egrep -o "[0-9.]{1,}"
But it returns
2014
11.2.0.4.3
Thanks!
You can probably use:
$ egrep -o "([0-9]{1,}\.)+[0-9]{1,}" file
11.2.0.4.1
([0-9]{1,}\.)+
matches at least one block of [0-9]{1,}
and a dot .
.[0-9]{1,}
matches a block of [0-9]
.So this will match any block of XX.YY
, being XX
any amount of blocks of ZZ.KK.TT.
and so on.
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