ipaddress: add a black line for each device to make the output more readable
Subsystems (2)
PATCH 1/1 ipaddress: add a black line for each device to make the output more readable
When we have multi links, the output huddled together and make it hard to read. Let's use the old ifconfig output style.
--- ip/ipaddress.c | 1 + 1 file changed, 1 insertion(+)
ip/ipaddress.c +1 -0
@@ -782,6 +782,7 @@ static int print_selected_addrinfo(int ifindex, struct nlmsg_list *ainfo, FILE *print_addrinfo (NULL , n, fp); } +fprintf (fp,"\n" );return 0 ; }
Signature · 1 line
1.8.1.4
2013/11/11 Hangbin Liu <[email protected]>:
Quoted 2 lines
When we have multi links, the output huddled together and make it hard to read. Let's use the old ifconfig output style.
For example:
Before:
# ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:10:18:f4:09:c4 brd ff:ff:ff:ff:ff:ff
inet 192.168.18.11/24 brd 192.168.18.255 scope global eth0
valid_lft forever preferred_lft forever
inet 192.168.100.1/24 scope global eth0
valid_lft forever preferred_lft forever
inet6 2012::1/64 scope global
valid_lft forever preferred_lft forever
inet6 2001::210:18ff:fef4:9c4/64 scope global dynamic
valid_lft 2086084sec preferred_lft 98884sec
inet6 fe80::210:18ff:fef4:9c4/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 00:10:18:f4:09:c5 brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 00:10:18:f4:09:c6 brd ff:ff:ff:ff:ff:ff
5: eth3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether 00:10:18:f4:09:c7 brd ff:ff:ff:ff:ff:ff
6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
state UP qlen 1000
link/ether 00:1b:21:a0:94:b6 brd ff:ff:ff:ff:ff:ff
inet6 2001::21b:21ff:fea0:94b6/64 scope global dynamic
valid_lft 2591897sec preferred_lft 604697sec
inet6 fe80::21b:21ff:fea0:94b6/64 scope link
valid_lft forever preferred_lft forever
7: eth5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether e4:1f:13:eb:c4:1a brd ff:ff:ff:ff:ff:ff
inet 10.66.86.93/23 brd 10.66.87.255 scope global eth5
valid_lft forever preferred_lft forever
inet 172.16.100.1/24 scope global eth5
valid_lft forever preferred_lft forever
inet6 2011::1/64 scope global
valid_lft forever preferred_lft forever
inet6 2620:52:0:4257:e61f:13ff:feeb:c41a/64 scope global dynamic
valid_lft 2086053sec preferred_lft 98853sec
inet6 fe80::e61f:13ff:feeb:c41a/64 scope link
valid_lft forever preferred_lft forever
8: eth6: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether e4:1f:13:eb:c4:1b brd ff:ff:ff:ff:ff:ff
9: eth7: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether e4:1f:13:eb:c4:1c brd ff:ff:ff:ff:ff:ff
10: eth8: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
link/ether e4:1f:13:eb:c4:1d brd ff:ff:ff:ff:ff:ffAfter:
# ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:10:18:f4:09:c4 brd ff:ff:ff:ff:ff:ff
inet 192.168.18.11/24 brd 192.168.18.255 scope global eth0
valid_lft forever preferred_lft forever
inet 192.168.100.1/24 scope global eth0
valid_lft forever preferred_lft forever
inet6 2012::1/64 scope global
valid_lft forever preferred_lft forever
inet6 2001::210:18ff:fef4:9c4/64 scope global dynamic
valid_lft 2086047sec preferred_lft 98847sec
inet6 fe80::210:18ff:fef4:9c4/64 scope link
valid_lft forever preferred_lft forever3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 00:10:18:f4:09:c5 brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 00:10:18:f4:09:c6 brd ff:ff:ff:ff:ff:ff
5: eth3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 00:10:18:f4:09:c7 brd ff:ff:ff:ff:ff:ff
6: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:1b:21:a0:94:b6 brd ff:ff:ff:ff:ff:ff
inet6 2001::21b:21ff:fea0:94b6/64 scope global dynamic
valid_lft 2591860sec preferred_lft 604660sec
inet6 fe80::21b:21ff:fea0:94b6/64 scope link
valid_lft forever preferred_lft forever7: eth5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether e4:1f:13:eb:c4:1a brd ff:ff:ff:ff:ff:ff
inet 10.66.86.93/23 brd 10.66.87.255 scope global eth5
valid_lft forever preferred_lft forever
inet 172.16.100.1/24 scope global eth5
valid_lft forever preferred_lft forever
inet6 2011::1/64 scope global
valid_lft forever preferred_lft forever
inet6 2620:52:0:4257:e61f:13ff:feeb:c41a/64 scope global dynamic
valid_lft 2086016sec preferred_lft 98816sec
inet6 fe80::e61f:13ff:feeb:c41a/64 scope link
valid_lft forever preferred_lft forever8: eth6: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether e4:1f:13:eb:c4:1b brd ff:ff:ff:ff:ff:ff
9: eth7: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether e4:1f:13:eb:c4:1c brd ff:ff:ff:ff:ff:ff
10: eth8: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether e4:1f:13:eb:c4:1d brd ff:ff:ff:ff:ff:ff
Quoted 21 lines
Signed-off-by Hangbin Liu <[email protected]>--- ip/ipaddress.c | 1 + 1 file changed, 1 insertion(+)ip/ipaddress.c +1
-1@@ -782,6 +782,7 @@ static int print_selected_addrinfo(int ifindex, struct nlmsg_list *ainfo, FILE *print_addrinfo (NULL , n, fp); } +fprintf (fp,"\n" );return 0 ; } --1.8.1.4
Quoted 2 lines · Hangbin Liu
When we have multi links, the output huddled together and make it hard to read. Let's use the old ifconfig output style.
No. You can't break others' scripts like that.
bash$ function ip { /sbin/ip "$@" | sed '2,$s/^[0-9]*:/\n&/' ; }
^^^ Here, fixed that for you.
Jiri
Signature · 1 line
Jiri Benc
Quoted 5 lines · Jiri Benc
Quoted 2 lines · Hangbin Liu
When we have multi links, the output huddled together and make it hard to read. Let's use the old ifconfig output style.
No. You can't break others' scripts like that.
Hi Jiri,
Thanks for you reminding.
Although I think a blank line won't have much influence for most of strong scripts, it MAY break some. But the output will be more readable. I think that worth it.
Quoted 2 lines
bash$ function ip {
/sbin/ip"$@" | sed '2,$s/^[0-9]*:/\n&/' ; }
Yes, this function works great. But for administrators who have lots of systems and NICs, it's hard to add the function/alias on each system. And the output of ifconfig, which is still used by lots of admins, looks clearly. So why don't we also use it?
Signature · 2 lines
Thanks & Best Regards Hangbin Liu <[email protected]>