There is number of ways to get external/public IP on linux console.
Here is couple of the quickest ones:
wget -q -O- http://replyip.com
curl -s http://replyip.com
You can also use it in your bash script :
IP=`curl -s http://replyip.com`
echo $IP