Learn about Linux
Download Linux
Get Linux help
Get special offers on:
Linux Application Dev Programming Software
Email:
#
Return to CLI Magic: Learn to talk awk
© Copyright 1999-2008 - SourceForge, Inc., All Rights Reserved About Linux.com - Privacy Statement - Terms of Use - Advertise - Trademark - Ask Linux Questions - Write for Us - RSS Feed ThinkGeek - Slashdot - SourceForge.net - freshmeat - Surveys - Jobs
shorter versions
Posted by: Anonymous Coward on February 01, 2006 02:11 AMifconfig | awk -F'[<nobr> <wbr></nobr>:]+' '{if ($3=="addr"){printf "%s:\t%s\n",Sv,$4}else{Sv=$1}}'
instead of
ifconfig | awk 'BEGIN{FS="[<nobr> <wbr></nobr>:]+"};{if ($3=="addr"){printf "%s:\t%s\n",Sv,$4}else{Sv=$1}}'
You could also lose the if, by using a next:
ifconfig | awk -F'[<nobr> <wbr></nobr>:]+' '/inet/{printf "%s:\t%s\n",Sv,$4;next};{Sv=$1}'
If you crunch it down any further than that you'll just end up with something unreadable to all but the illuminati. Like the average perl program!<nobr> <wbr></nobr>;)
#