Find out the IP address of eth0 and display IP only

 

Now you just wanted the IP address, use grep to get the IP:
$ /sbin/ifconfig eth0| grep 'inet addr:'Output:

inet addr:192.168.2.1  Bcast:192.168.2.255  Mask:255.255.255.0

To get IP address from use cut command:
$ /sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2Output:

192.168.2.1  Bcast

Finally remove Bcast with awk
$ /sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
Output:

192.168.2.1