I'm trying to gather information on the interfaces on a large number of servers.
If I run ifconfig I will get: eth0 Link encap:Ethernet HWaddr 00:50:56:A2:27:C1
inet addr:10.145.xxx.xxx Bcast:10.152.45.255 Mask:255.255.254.0
-----
eth1 Link encap:Ethernet HWaddr 00:50:56:A2:1D:21
inet addr:10.145.xxx.xxx Bcast:10.136.27.255 Mask:255.255.254.0
------
I have tried :
/sbin/ifconfig -a | egrep "inet|Link" | awk '{ if ( $2 == "Link" ) {print $1} else { if( $1 == "inet" ) { print $2 }}}'
Which gives me:eth0
addr:10.152.44.18
eth1
addr:10.136.26.137
What I want is this:eth0 addr:10.145.xxx.xxx
eth1 addr:10.145.xxx.xxx
Some interfaces do not have addresses so I cant just concatenate sequential lines. Is there a simple way for me to get the format I'm looking for ?
Thanks