Reputation: 1
I want to display all network interface for a script, including vip.
~]$ /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:90:88:37
inet addr:192.168.1.15 Bcast:192.168.1.31 Mask:255.255.255.224
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9786341 errors:0 dropped:152 overruns:0 frame:0
TX packets:10162602 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6846599961 (6529.4 Mb) TX bytes:2951709145 (2814.9 Mb)
eth1 Link encap:Ethernet HWaddr 00:50:56:90:E1:2E
inet addr:25.10.100.15 Bcast:25.10.100.31 Mask:255.255.255.224
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:42436 errors:0 dropped:150 overruns:0 frame:0
TX packets:35 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5484037 (5.2 Mb) TX bytes:2446 (2.3 Kb)
Like this
eth0 00:50:56:90:88:37 192.168.1.15 MTU:1500
eth0 00:50:56:90:E1:2E 25.10.100.15 MTU:1500
Please help to get this
Thanks in advance
Upvotes: 0
Views: 574
Reputation: 69208
You can use awk
and set the record separator to an empty line, for example this
/sbin/ifconfig | awk -v RS='' '{print $14}'
will print
MTU:1500
MTU:1500
so just pick the fields you want.
Upvotes: 2