'for' loop advice needed ....!!

/usr/sbin/ifconfig -a | grep "inet" | grep -v "inet6" | grep -v "127.0.0.1" | 
grep -v "0.0.0.0"|grep -v "192.168.100.2" | awk '{print $2}'

I use above command to get IP addresses on AIX boxes.Values coming here are set to a variable "Host IPs.IP Addresses" in my fingerprinting engine.

Next,i am trying to get interface names associated with these IPs.

So i write

for INTERFACE in `/usr/sbin/ifconfig -a | nawk '$1 ~ /:$/ && $1 !~ /^lo/ {sub(":$", "", $1); print $1}'`
do
        val=`/usr/sbin/ifconfig $INTERFACE | grep  "@@Host IPs.IP Addresses@@"`
        if [ ! -z $val ]
        then     
        echo $INTERFACE
        fi          
done

Issue:

I have some boxes where i can see duplicate IP addresses ,exactly same.These redundant IPs are causing trouble to above 'for' loop.When my CSV is generated ,i see following rows

<HOSTNAME>        <IP>   <NETMASK>   <DNS>      2010-01-12      en0et0
<HOSTNAME>        <IP>   <NETMASK>   <DNS>      2010-01-12      en0et0

As you can see ,last column is for interface name.

Since 'en0' and 'et0' are two diffrent interfaces but associated with same IP,above loop is faling.

Kindly advice.

Regards
Abhi

It would help if you post the full "ifconfig -a" output.

en0: flags=5e080863,c0<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),PSEG,CHAIN>
        inet <NUMERIC_ADDRESS1> netmask 0xffffff00 broadcast <NUMERIC_ADDRESS2>
en1: flags=5e080863,c0<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),PSEG,CHAIN>
        inet <NUMERIC_ADDRESS1> netmask 0xfffff000 broadcast <NUMERIC_ADDRESS2>
         tcp_sendspace 131072 tcp_recvspace 65536
et0: flags=5e080863,80<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),PSEG,CHAIN>
        inet <NUMERIC_ADDRESS1> netmask 0xffffff00 broadcast <NUMERIC_ADDRESS2>
lo0: flags=e08084b<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT>
        inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255
        inet6 ::1/0
         tcp_sendspace 65536 tcp_recvspace 65536

<NUMERIC_ADDRESS1> is IP address ,which is same for both interfaces 'en0' and 'et0'
and
<NUMERIC_ADDRESS2> is of course,the broadcast address ,which is diffrent for both interfaces.

ifconfig -a | awk '/lo0:/{exit}$1 ~ /:$/{nic=$1}$1=="inet"{print nic,$2,$NF}'

I am not sure how do i use this .

the 'in' statement is returning me the interface names in order.....