Linux.com

Re:Get a list of your interface addresses

Posted by: Anonymous Coward on February 01, 2006 12:12 AM
Using a BEGIN rule to define a regex field separator

ifconfig | awk 'BEGIN{FS="[<nobr> <wbr></nobr>:]+"};{if ($3=="addr"){printf "%s:\t%s\n",Sv,$4}else{Sv=$1}}'

Mad props to Arnold Robbins, GNU awk maintainer! gawk is quite a bit more useful than real awk, and recent versions include socket IO in a simple easy syntax.

The above is not necessarily the easiest or most concise way to solve the problem, it's off the top of my head right now.

--Charlie

#

Return to CLI Magic: Learn to talk awk