[ale] scripting challenge du'jour

J. D. jdonline at gmail.com
Wed Jul 5 20:35:22 EDT 2006


I'm sure there are much better ways but here is my stab at it.

#!/bin/bash
# script to parse the output of ifconfig

IFACE1=eth0
IFACE2=eth1

echo "$(/sbin/ifconfig $IFACE1 |grep inet |grep -v inet6 |cut -d":" -f2 |cut
-d" " -f1)"      "$(/sbin/ifconfig $IFACE1 |grep inet |grep -v inet6 |cut
-d":" -f4 |cut -d" " -f1)"

echo "$(/sbin/ifconfig $IFACE2 |grep inet |grep -v inet6 |cut -d":" -f2 |cut
-d" " -f1)"      "$(/sbin/ifconfig $IFACE2 |grep inet |grep -v inet6 |cut
-d":" -f4 |cut -d" " -f1)"


On 7/5/06, Jim Popovitch <jimpop at yahoo.com> wrote:
>
> What's the fastest, cleanest, most optimized, shell script (non perl,
> etc) method to take the output of ifconfig and produce a list that
> resembles this:
>
> 192.168.4.5/255.255.255.0       192.168.4.255
> 172.16.8.12/255.255.0.0         172.16.255.255
>
>
> Go!
>
> -Jim P.  (TIA ;-))
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>
-------------- next part --------------
An HTML attachment was scrubbed...




More information about the Ale mailing list