I am trying grep only the numbers from the end of the string until any other char, so from example:
"Version 1.2.34"
Will give me '34'
to variable $minor
and 'Version 1.2.'
to variable $type
I manage to
minor=$(grep -Eo '[0-9]{1,24}')
but this gives me ALL numbers.
CodePudding user response:
Using pure bash
:
s="Version 1.2.34"
minor="${s##*[!0-9]}"
type="${s%$minor}"
declare -p type minor
declare -- type="Version 1.2."
declare -- minor="34"