$ ip a | grep <interface> | grep inet | cut -f1 -d/ | awk '{print $2}'
or if your locale is set to english
$ ifconfig <interface> | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
replace addr by adr may work in other languages like french
$ wget -qO - checkip.dyndns.org | sed -e 's/[^0-9^.]//g'
You can also use ifconfig.co service
$ wget -qO - ifconfig.co