Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formatting input on different lines 2

Status
Not open for further replies.
Apr 13, 2004
316
US
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000


Given the above line from ifconfig, how do I get it so it prints like this (there are multiple adapters (6) in the server, too, besides the loopback, that need formatted):
lo0: 127.0.0.1

Thanks!
 
Something like this ?
ifconfig -a | '$1~/:$/{f=$1;getline;print f,$2}'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
or something like this:

Code:
ifconfig -a | nawk -F '[: ]' '/flags=/ { inter=$1; next} {print inter, $2}'

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top