Extract all first numeric character from a string

Hello,

I have a file of strings a below:-

4358RYFHD9845
28/COC/UYF984
9834URD 98HJDU

I need to extract all the first numeric character of every sting as follows:-

4358
28
9834

thanks to suggest ASAP

Regards,
Jasi

If your grep version supports -o

grep -oE '^[0-9]+' file

Another one with sed:

$ sed 's/^\([0-9]\+\).*/\1/' infile
4358
28
9834

I guess you meant group of numeric chars, not a single one. Try

sed 's/[^[:digit:]].*$//' file
4358
28
9834

Hi
In buit-in bash:

while read ; do echo ${REPLY%%[^[:digit:]]*}; done <file
4358
28
9834

Regards.

Could try:

tr -d [:alpha:] < sample.txt 

hth

EDIT:
Misread, nevermind.
This removes all letters from the file.

Standard sed:

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

Note that OP specified a requirement to extract all the first numeric characters, which is different from "all numeric characters that appear at the start of the line" ..
So it would seem that something like this should be more appropriate..

sed -n 's/^[^0-9]*\([0-9][0-9]*\).*/\1/p' file