hostname -I or hostname --all-ip-addresses which gives you all addresses for the host, IPV4s as well as IPV6s. Check hostname -h for more nifty detailsifconfig is for configuring a network interface. (Interface Configuration)
1ifconfig $1 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'

grep prints lines mathcing a pattern
awk is a pattern scanning and processing language.
See more about linux interface. ifconfig -l on a Mac lists all inetrfaces available.
1ifconfig |grep -B1 "inet addr" |awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' |awk -F: '{ print $1 ": " $3 }'

1ifconfig eth | grep --color 'inet6'

OR
1ifconfig eth | grep 'inet6' | awk '{print $3}'

You can curl an endpoint for your external public IP, like so:
1curl http://ipecho.net/plain; echo
There are plenty of services that give you your public IP address by going to a URL. You can then curl that URL to see your extrenal public IP in CLI.
Some alternatives are:
1curl http://ip.appspot.com/
2curl https://icanhazip.com/