[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to get an IP address



On Tue, 15 Nov 2011 15:50:26 -0700, Bob Proulx wrote:

>> . . . how to get *only* the IP address of my current
>> Intranet address 192.168...?

Thanks for your answer Bob, 

> Or if you don't like loopback addresses showing up in the list:
> 
>   $ ip addr show | awk '/ inet / && !/127\./{print$2}'

and I don't like the "/24" that follows the IP address. so I made a small 
tweak based on your solution:

 ip -f inet addr | awk '/ inet / && !/127\./{sub(/\/.*/, "", $2); print 
$2}'

thanks

-- 
Tong (remove underscore(s) to reply)
  http://xpt.sourceforge.net/techdocs/
  http://xpt.sourceforge.net/tools/


Reply to: