[Tfug] net

Rich r-lists at studiosprocket.com
Fri May 9 18:04:25 MST 2008


On May 4, 2008, at 4:32 pm, Glen Pfeiffer wrote:

> On 04/05/08 16:23 -0700, ray reeves wrote:
>> Is there a command to list all my network devices IP addresses?
>
> As root:
why?

/sbin/ifconfig is enough for me. Are you using SELinux or something?


> ifconfig
>
> It lists more than just the addresses. So just look for the inet
> addr: section.

This is why the Good Lord gave us grep and sed and for loops!

for n in $( /sbin/ifconfig -l ) ; do echo $n:$( /sbin/ifconfig $n |  
grep "inet "| sed -e 's/.*inet //' -e 's/  *.*//' ) ; done

This was on a Mac. ifconfig -l means "list interfaces". My output:

lo0:127.0.0.1
gif0:
stf0:
en0:
en1:192.168.0.64
fw0:

Rich




More information about the tfug mailing list