Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: how do I find my IP address



--- Jason Price <jprice@xxxxxxxxxxxxxxxxxxxx> wrote:

> On most unix flavors, some varient of:
> 
> ifconfig -a | grep inet | grep -v '127.0.0.1' | awk
> '{print $2}'
> 
> should work.  'ifconfig' can live in various places,
> but usually it
> is in /sbin/ifconfig or /usr/sbin/ifconfig (old
> unixen might have it in /etc/ifconfig).

> I'm sure there's a way to figure out a pure zsh way
> to do this, but I don't know it. 

The purest I could think of was eliminating awk, which
can be done like this:

foo=`ifconfig | grep inet | grep -v '127.0.0.1'`
baz=($=foo)

Now $baz[2] contains the ip address. I guess you could
get the address by poking /proc, but that's not very portable.


	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 



Messages sorted by: Reverse Date, Date, Thread, Author