Solved

AWK and splitting a string into an array

Posted on 2007-03-26
3
825 Views
Last Modified: 2012-06-27
Wrote a script to pull all the various Interface IPs from a list of routers.  Output from snmpwalk is in the following format:
ipAdEntIfIndex.192.168.100.106 = INTEGER: 10

Want to add a pipe to the end of my snmpwalk statement that would run it through awk and then output just the ip address (192.168.100.106).  Pretty sure I need to split this into an array within awk and then tweak the formatting but have never done this before.  Any assistance would be appreciated.

Thanks.
0
Comment
Question by:lourite
  • 2
3 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 18795305
echo "ipAdEntIfIndex.192.168.100.106 = INTEGER: 10" | awk '{sub(/[^.]*./,"");sub(/ .*/,"");print}'
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 18795320
echo "ipAdEntIfIndex.192.168.100.106 = INTEGER: 10" | awk -F'[. ]' '{OFS=".";print $2,$3,$4,$5}'
0
 

Author Comment

by:lourite
ID: 18799224
Thanks for the help ozo.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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