@isthistheend
I was pretty sure my message came before yours yesterday...
Anyway, I just redesigned awk script a bit to add "no IP" output and a few comments:
Code:
# First we skip interfaces we don't want shown
# Comment out if want to display them too
/lo0/||/enc/{next}
# We remember interfaces in iface variable, and increase gotif
# If we get more that 2 interfaces it means last one doesn't have an address
# so we put it in noip array and decrease the gotif counter
/flags/{
if(++gotif>1){noip[iface]++; gotif--}
iface=$1
}
# We found an address. We put interface and address in buf array
# and decrease counter by 1
/inet /&&gotif{
buf[iface]=$2
gotif--
}
# END block
END{
# If we still have counter set it means there is last interface
# that doesn't have an address so we include that one too
if(gotif>=1) noip[iface]++
# We print out both arrays
for(i in buf) printf("%s\t%s\n", i, buf[i])
for(j in noip) printf("%s\tNo address\n", j)
}
Try to call it as:
Code:
ifconfig -a | awk -f thascript.awk
I leave to you to get "status" message displayed in output, just make sure you post it here in case someone else needs it as well.
All best