#!/bin/bash
# lists address and length for given interface

set -eu

ip addr show  | while read -r line
do
   if [[ "$line" =~ 'inet ' ]]		# a match
   then
       ippair=$(echo $line | cut -d' ' -f2)
       addr=$(echo $ippair|cut -d/ -f1)
       len=$(echo $ippair|cut -d/ -f2)
       echo $addr $len
   fi   
done
exit 0


