for i in $(/sbin/ifconfig | grep addr: | cut -d’:’ -f2 | cut -d’ ‘ -f1 | grep -Ev ‘^$’); do echo -n $i”, “; done | sed -r s/’, $’/”/g; echo
for i in $(/sbin/ifconfig | grep addr: | cut -d’:’ -f2 | cut -d’ ‘ -f1 | grep -Ev ‘^$’); do echo -n $i”, “; done | sed -r s/’, $’/”/g; echo
Looks like "done" turned into "one". I needed the same one-liner a while back, based it on ip:
/sbin/ip addr list | sed -n 's/inet (.*)/.*/1,/p' | xargs | sed 's/,$//'
Amazing it takes stuff like this to get a list of IPs.
indeed! thanks!
Here's a FreeBSD version:
/sbin/ifconfig -a | /usr/bin/grep netmask | /usr/bin/awk '{print $2}'
This is what I love about the *nix way of life. there's always so many ways of doing things. What differentiates the men from the boys (as it were) is not how something gets done but that something gets done. 😀
Here's one more (worked on CentOS/Fedora/RedHat-like distros):
/sbin/ifconfig [OPTIONAL_DEVICE_NAME] | grep "Bcast" | awk -F ' ' '{print $2}' | awk -F ':' '{print $2}'
-g