Fully respecting what @ocicat has suggested, now that J65nko has modified OPs attempt, I'll try with awk only:
Code:
$ ifconfig -a | awk ' \
/lo/||/enc/ {next}
/flags/ {iface=$1}
/inet /&&iface {buf[iface]=$2}
END{for(i in buf)printf("%s\t%s\n", i, buf[i])}'
__________________
The best way to learn UNIX is to play with it, and the harder you play, the more you learn.
If you play hard enough, you'll break something for sure, and having to fix a badly broken system is arguably the fastest way of all to learn. -Michael Lucas, AbsoluteBSD
|