Skip to content

Instantly share code, notes, and snippets.

@bitboss-ca
Created April 9, 2013 17:19
Show Gist options
  • Save bitboss-ca/5347560 to your computer and use it in GitHub Desktop.
Save bitboss-ca/5347560 to your computer and use it in GitHub Desktop.
A handy way to get your public IP address from a command line. This has been tested on Mac and FreeBSD.
#!/bin/sh
curl -s https://www.google.ca/search\?q\=whats+my+ip | awk '{print substr($0,index($0,"Client IP address"),34)}' | cut -d ')' -f 1 | head -n1 | sed 's/Client/Public/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment