AWK and splitting a string into an array

Posted on 2007-03-26
Medium Priority
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. = 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 (  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.

Question by:lourite
  • 2
LVL 85

Expert Comment

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

Accepted Solution

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

Author Comment

ID: 18799224
Thanks for the help ozo.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

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 demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
If you are looking for an automated tool which can generate reports for Outlook emails and other items from PST file, then you can go for Kernel PST Reporter tool. The reports which are created by this tool are helpful to analyze and understand PST …
To export Lotus Notes to Outlook PST or Exchange and Domino Server files to Exchange Server or PST files with ease, go for Kernel for Lotus Notes to Outlook conversion tool. Through the video, you can watch the conversion process. A common user with…

619 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