This question already has an answer here:
I've just completed a lengthy installation script that deploys a Ruby on Rails application unto web servers. At the end of this script, I'd like it to print something along the lines of: "Installation Complete. Access
0.0.0.0 is the server's public IP address.
I've found several free services that do this. I can successfully identify the server's IP address using either of the following:
dig @ns1.google.com -t txt o-o.myaddr.l.google.com +short
I would like to identify the server's public IP address, save the result to a variable defined at the beginning of the shell script and print it to the end user at the end of installation.