Solved

shell scripting match leading numbers

Posted on 2011-09-13
1
308 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

752 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