just wanted to extract a number included in a path path is stored in catalina_home string as "/opt/hpws24/tomcat" so How to extract 24
I tried
catahome='/opt/hpws24/tomcat'
version=$(echo "$catalina_home" | grep -o -E '[0-9]+')
echo $version
which is giving me 24 but still i want only the number which attached to hpws because my code is giving all the numbers with space separated in case opt or tomcat is having a number sttached in future, So i want only a number attached 2 hpws. please guide me