getting own ip address

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?

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

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