# getting own ip address

**URL:** <https://community.unix.com/t/getting-own-ip-address/220909>\
**Category:** Solaris\
**Created:** [November 17, 2008, 9:45am UTC](https://community.unix.com/t/getting-own-ip-address/220909 "2008-11-17T09:45:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vickylife](https://community.unix.com/letter_avatar/vickylife/32/6_22734026db12803ebb3e059622ac3534.png) [@vickylife](https://community.unix.com/u/vickylife)\
**Post date:** [November 17, 2008, 9:45am UTC](https://community.unix.com/t/getting-own-ip-address/220909/1 "2008-11-17T09:45:36Z")

</div>

Can someone tell me what is the best way to get your ip address through a command line command.

cat /etc/hosts | grep `hostname` | awk '{print $1}'  
gives 2 ip.  
127.0.0.1 and actual ip address

while ifconfig -a gives a lot of information and its difficult to get ip address in between.

Is there is any direct command?

---

<div class="post-metadata">

**Author:** ![System\_Shock](https://community.unix.com/user_avatar/community.unix.com/system_shock/32/368_2.png) [@System\_Shock](https://community.unix.com/u/System_Shock)\
**Post date:** [November 17, 2008, 10:18am UTC](https://community.unix.com/t/getting-own-ip-address/220909/2 "2008-11-17T10:18:32Z")

</div>

No need for the cat. Add a grep-v pipe.

```nohighlight
grep `hostname` /etc/hosts | grep -v 127.0.0.1 | awk '{print $1}'

```
