Re: one liner sed or awk
In article <1180503661.602541.126320@q69g2000hsb.googlegroups .com>,
<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,DEPR ECATED,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
>
from the dirty tricks department:
ifconfig -a \
awk '/flags/ {sub(":$","",$1);f=$1;} /inet/ {printf ("%s\t%s\n",f,$2)}'
Note: This will generate a separate, full, line for each address assigned to
an interface with multiple addresses.
|