shell scripting match leading numbers

In shell scripting I need to yank out leading numbers,  in the examples host below I need it to match any leading numbers then stop whenever the next characters is not number.

example:

99-host-01.com
result I want:  99

1000-host.com
result I want: 1000

host999.com
result I want: nothing
phatbrain101Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
pivarConnect With a Mentor Commented:
Hi,

How about? If it's from a file.

grep -o '^[0-9]*' filename

/peter
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.