Extract integer from string using bash
For a bash-only solution, you can use parameter patter substition:
pax$ xyz=ABC3 ; echo ${xyz//[A-Z]/}3pax$ xyz=DFGSS34 ; echo ${xyz//[A-Z]/}34pax$ xyz=CVBB3 ; echo ${xyz//[A-Z]/}3
It's very similar to sed
solutions but has the advantage of not having to fork another process. That's probably not important for small jobs but I've had situations where this sort of thing was done to many, many lines of a file and the non-forking is a significant speed boost.