Solved

shell scripting match leading numbers

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

A short article about a problem I had getting the GPS LocationListener working.
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.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now