How do I remove all letters until the first digit with sed?

Viewed 77

I have the following lines:

XYZ2342
ABCD1323
KIL9824

And I would like to remove all letters at the beginning, so I would get for the above example:

2342
1323
9824

I have tried this:

echo "ABC12345" |  sed 's/[[:alpha:]]*[[:digit:]]//'
2345

But it also removes the first digit, how can I make sed to delete just the letters (note: they are always ASCII).

I am using FreeBSD sed implementation, in case that is relevant.

1 Answers

Could you please try following. We need to substitute everything till first occurrence of digits from starting so we need to use [^0-9] regex here, which means from starting substitute everything till first occurrence of digits with NULL here.

echo "ABC12345" | sed 's/^[^0-9]*//'
Related