How can I extract the beginning alphabetic letters from a string? I want to extract alphabets occurring in the beginning before I hit the first non-alphabetic character.
e.g. If the input string is abcd045tj56 the output should be abcd
Similarly, if the input is jkl657890 the output should be jkl
Can it be done in shell script using awk/sed/cut?
I tried
echo "XYZ123" | awk 'sub(/[[:alpha:]]*/, "")'
But it gives 123 instead of xyz
Then I tried
echo "XYZ123" | awk '{print (/[[:alpha:]]*/)}'
but it gives 1
I want the answer to be XYZ