Solved

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

Posted on 2013-02-06
2
253 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

759 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

20 Experts available now in Live!

Get 1:1 Help Now