This is a script which will show you IP address assigned to your machine. This script even take cares even if the host have multiple interfaces and shows the assigned IP address.

#Purpose: To show the IP address of a machine
#Author:Surendra Anne
#Date: 2012-09-11
#Licence: GPLv3

for i in `ifconfig | cut -d” ” -f1 | sort | grep -v ‘^$’`
if ifconfig $i | grep addr: &> /dev/null
echo “The interface $i have IP Address:$(ifconfig $i | grep addr: | awk ‘{print $2}’ | cut -d”:” -f2)”

Your are free to add/modify this script and use it for your purpose. Some of the tools used here are

SORT command
cut command
ifconfig command
grep command
redirection operation
echo command
awk command
for loop
if statement

Related concept:   Shell script: check if two files are havings same permissions or not