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

Re: How to get an IP address



T o n g wrote:
> Now a related question, how to get *only* the IP address of my
> current Intranet address 192.168...?
> 
> Is there easier answers than analysing results from the following?
> 
>  ifconfig eth0
>  ip addr
>  ip -f inet addr

Please remember that hosts have devices and devices have addresses.
Therefore a host might have many addresses.  Here is one way:

  $ ip addr show | awk '/ inet /{print$2}'

Or if you don't like loopback addresses showing up in the list:

  $ ip addr show | awk '/ inet / && !/127\./{print$2}'

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: