Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Linux Programming, 2nd Edition section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 7th, 2005, 06:21 AM
Registered User
 
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ankurg
Default Please Help

I want to extract the last 3 digits of my IP Address without using GREP command. Please help me for extracting out of this problem.

Thanks in Advance

Any Suggestion will be appreciable.

-Ankur

 
Old March 16th, 2005, 11:58 AM
Friend of Wrox
 
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

$ ifconfig | perl -pe 's/.*\n// unless /inet/;' | awk '{print $2}' | perl -pe 's/.*\.(\d{1,3}$)/$1/'

Why would you not want to use grep, though?



--
Don't Stand on your head - you'll get footprints in your hair. http://www.charlieharvey.org.uk









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.