To just get your IP address:
echo `ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'`
This will give you the IP address of eth0.
Edit: Due to name changes of interfaces in recent versions of Ubuntu, this doesn't work anymore. Instead, you could just use this:
hostname --all-ip-addresses
or hostname -I
, which does the same thing (gives you ALL IP addresses of the host).