I generally use
/usr/sbin/ifconfig -a | grep "inet" |egrep -v "inet6|0.0.0.0|192.168.100.2"|awk '{print $2}'
to capture IPs on a host.
Now here is what i have:
bash-2.05$ /usr/sbin/ifconfig -a
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet <IP> netmask ff000000
lo0:1: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet <IP> netmask ff000000
lo0:2: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet <IP> netmask fffffff8
lo0:3: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet <IP> netmask fffffff8
lo0:4: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet <IP> netmask fffffff8
lo0:5: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet <IP> netmask fffffff8
lo0:6: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet <IP> netmask fffffff8
lo0:7: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet <IP> netmask fffffff8
lo0:8: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet <IP> netmask fffffff8
ce0: flags=9040843<UP,BROADCAST,RUNNING,MULTICAST,DEPRECATED,IPv4,NOFAILOVER> mtu 1500 index 2
inet <IP> netmask ffffff80 broadcast <BROADCAST>
groupname ipmp
ce0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet <IP> netmask ffffff80 broadcast <BROADCAST>
ce1: flags=9040843<UP,BROADCAST,RUNNING,MULTICAST,DEPRECATED,IPv4,NOFAILOVER> mtu 1500 index 3
inet <IP> netmask ffffff80 broadcast <BROADCAST>
groupname ipmp
ce1:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
inet <IP> netmask ffffff80 broadcast <BROADCAST>
ce5: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 4
inet <IP> netmask fffffc00 broadcast <BROADCAST>
As you can see,i have multiple loopbacks configured.I wish not to capture these IP addresses.I just want it to capture IP address which are not loopback i.e in above example..IPs for 'ceo'...etc...
Kindly advice
Abhi