Bash – `ip addr` in one-line per interface

awkbaship

I would like to print specific information about network configuration for different interfaces over all the servers I manage:

  • the interface name
  • the interface ipv4 address
  • the interface hardware mac address

Unfortunately, a simple ip -o addr show doesn't allow to parse easily its output with awk because of the line-breaks.

Is it possible to have ip addr show printed on exactly one line per interface?

Else, is it possible to achieve the same result using awk and/or sed? This goes beyond my knowledge of those two commands since the lines have to be concatenated tree by tree…

Best Answer

Just use --brief flag.

ip --brief address show
Related Question