Solved

shell scripting match leading numbers

Posted on 2011-09-13
1
309 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:phatbrain101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 22

Accepted Solution

by:
pivar earned 250 total points
ID: 36532685
Hi,

How about? If it's from a file.

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

/peter
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Six Sigma Control Plans
Starting up a Project

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question