Solved

How do I get a list of all the ipaddresses in one string?

Posted on 2013-02-06
2
255 Views
Last Modified: 2013-02-07
Hi
How do I get a list of all the ipaddresses (that is not 127.0.0.1) in one string?
IPv4 and IPv6 addresses.
so return "IP:10.20.30.1, IP:10.20.30.2, IP:3030:0:110:715:150:51ff:fe82:4f15"

Thanks
Jamie
0
Comment
Question by:jamie_lynn
2 Comments
 
LVL 19

Accepted Solution

by:
bevhost earned 500 total points
ID: 38862398
#!/bin/bash
for line in `ip addr show | grep inet | grep -v host | cut -d\  -f6 | cut -d/ -f1 `; do
        if [ "x$str" == "x" ]; then
                str="IP:$line"
        else
                str="$str, IP:$line"
        fi
done
echo $str

Open in new window

0
 

Author Closing Comment

by:jamie_lynn
ID: 38865027
Works great! Thanks!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
partition customisation for kickstart file 2 94
CentOS 6.6 Port opening question 1 137
mysql server issue in linux server 5 62
init script for deployment on linux machine 5 53
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

786 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