Wednesday, August 06, 2014

awk and ifconfig

Print interface name and network config oneliner.


#ifconfig -a | awk '/^[a-z]/{intf=sprintf("%-10s", $1);getline; if($1=="inet") printf "%-6s %s\n", intf, $0;}'
          inet addr:172.19.2.26  Bcast:172.19.2.255  Mask:255.255.255.0
          inet addr:127.0.0.1  Mask:255.0.0.0

No comments: