30/05/2007, 13h19
|
#2
|
|
|
Re: one liner sed or awk
Seve.Paritos@gmail.com wrote:
> hello everyone.
> I have the following ifconfig output on solaris and want to be able to
> get the output from it in the following format using a one liner.
>
> ce0 192.168.13.50
> ce0:1 192.168.13.245
> ce0:2 192.168.13.64
> ce0:3 192.168.13.62
> ce1 192.168.13.51
>
> bash-2.05$ ifconfig -a
> lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index
> 3
> inet 127.0.0.1 netmask ff000000
> ce0:
> flags=9040843<UP,BROADCAST,RUNNING,MULTICAST,DEPRE CATED,IPv4,NOFAILOVER>
> mtu 1500 index 4
> inet 192.168.13.50 netmask fffffc00 broadcast 192.168.15.255
> groupname amazon_ipmp_bk
> ce0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500
> index 4
> inet 192.168.13.245 netmask fffffc00 broadcast 192.168.15.255
> ce0:2: flags=1000842<BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index
> 4
> inet 192.168.13.64 netmask fffffc00 broadcast 192.168.15.255
> ce0:3: flags=1000842<BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index
> 4
> inet 192.168.13.62 netmask fffffc00 broadcast 192.168.15.255
> ce1:
> flags=9040843<UP,BROADCAST,RUNNING,MULTICAST,DEPRE CATED,IPv4,NOFAILOVER>
> mtu 1500 index 5
> inet 192.168.13.51 netmask fffffc00 broadcast 192.168.15.255
> groupname amazon_ipmp_bk
>
> Thanks
>
It's hard to tell how much of the formatting above is due to
linewrapping in your posting, but try this:
awk 'key ~ /^c/{print key,$2} {key = sub(/:$/,"",$1) ? $1 : ""}'
Ed.
|
|
|
|