sed - delete everything until the first digit comes up

Hi,

I have a text file with content as follows:

bla foo3200492
comment on this: 3900302
here comes the teddy 12

all I need is:

3200492
3900302
12

So I need the correct "sed" command to delete everything until the first number.

I am not a regex expert, because I have to use it very barely so I would appreciate if anyone can help me here :slight_smile:

Hi

sed 's/[^0-9]*//' file

Guru.

3 Likes
echo "blah blah 1234" | tr -d [:alpha:]

would remove all of the characters

echo "blah blah 1234" | tr -cd [:digit:]

would remove anything but digits

If you only need delete everything until the first number, guruprasadpr's code is enough.

but from your sample file, seems you need output last column. you can try this:

awk '{print $NF}' urfile