Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Equivalent solution for gettimezoneinformation 12 116
File system unmounted 3 155
Install Apache on a Mac with Homebrew | Apache Config Issues 1 166
Openwrt vnstat 9 156
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 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

13 Experts available now in Live!

Get 1:1 Help Now