Solved

AWK and splitting a string into an array

Posted on 2007-03-26
3
820 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

15 Experts available now in Live!

Get 1:1 Help Now