Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed substring extraction 1

Status
Not open for further replies.

adumitrescu

Programmer
Jun 15, 2005
18
CA
Hello,

I've got a string that looks like this:
[blah]A1-18[blah]n.n.n.n[blah]
where [blah] is one or more chars and n is one or more digits. This string lives in a file called 'status' (on Linux 2.4). I need to return only the IP from this string. Here's what I've got so far:
sed -n 's/.*A1-18.*\(\d*\.\d*\.\d*\.\d*\).*/\1/p' status

The command runs without error, but returns nothing. Suggestions? -thanks
 
A starting point (not waterproof):
sed -n 's/.*A1-18[^0-9]*\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/\1/p'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks, PH. Indeed, it was my use of \d that jammed things up (too much Perl'ing).
-cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top