Skip to content

Instantly share code, notes, and snippets.

@koehn
Last active December 29, 2015 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koehn/7628485 to your computer and use it in GitHub Desktop.
Save koehn/7628485 to your computer and use it in GitHub Desktop.
Send the current IPv6 address to stdout.
#!/bin/bash
CHECK_IP=`curl -6 -m 5 http://www.whatismyipv6.com/ 2> /dev/null | awk '/^[0-9a-f:]+<tr><td>/ { sub(/<.*/, "") }; { print $0 }' | egrep '^[0-9a-f:]+$'`
if [ $? -ne 0 ]
then
echo Unable to get current IP address with curl >&2
exit 100
fi
echo $CHECK_IP | sed -e 's!.*is \(.*\)</h1>.*!\1!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment