I found this today in one of the forums. I thought that it is quite handy. If you want to know your public IP address you can use this command in bash or other shells.
dig +short myip.opendns.com @resolver1.opendns.com
Just add it as an alias in your .bashrc file.
alias myWANIP=’dig +short myip.opendns.com \@resolver1.opendns.com’
[root@centos6 ~]# myWANIP