I have a variable which looks like AbcDef123 and I want to extract the 123 portion. I can quite happily use
or
but these seem like a hammers to crack a nut. I've tried
but it's not returning what I want, as you can see. I tried
which shows that it's interpreting [^0-9] as 09 and '^', not 'not a number' as I wanted.
Any ideas?
Thanks
Ceci n'est pas une signature
Columb Healy
Code:
expr $testvar : "[^0-9]*\([0-9]*\)"
Code:
echo $testvar | tr -d '[A-Za-z]'
Code:
# testvar="AbcDef123"
# echo ${testvar##[^0-9]*}
AbcDef123
# echo ${testvar##[A-Za-z]*}
#
Code:
# echo ${testvar%%[^0-9]*}
AbcDef
Any ideas?
Thanks
Ceci n'est pas une signature
Columb Healy