Using ifconfig was not a good idea at all.
Here is a more distro-agnostic way:
ip addr show eth0 | grep "inet "| awk '{ print $2}' | awk -F '/' '{ print $1 }'
# set the language to English, to avoid translation problems with ifconfig
export LANG=C
# get IP address of eth0 network interface
ifconfig eth0 | awk '/inet addr/ {split ($2,A,":"); print A[2]}'
source