Skip to content

Instantly share code, notes, and snippets.

@carlosmcevilly
Created December 27, 2012 00:28
Show Gist options
  • Save carlosmcevilly/4384342 to your computer and use it in GitHub Desktop.
Save carlosmcevilly/4384342 to your computer and use it in GitHub Desktop.
expand a bit.ly URL to its original URL. Need a bit.ly developer account to use this.
#!/bin/bash
# change these to your own
export userid=<user_id_string_from_bitly_account>
export key=<key string_from_bitly_account>
export link=$1
if [[ "$link" == '' ]]
then
echo usage: $0 '<link>'
exit -1
fi
export expand="http://api.bit.ly/v3/expand?shortUrl=$link&login=$userid&apiKey=$key&format=txt"
wget -q --output-document=temp.txt.$$ $expand
cat temp.txt.$$
/bin/rm temp.txt.$$
@carlosmcevilly
Copy link
Author

Here's another way, from user atoponce at commandlinefu.com, using a service of longurl.org:

expandurl() { curl -s "http://api.longurl.org/v2/expand?url=${1}&format=php" | awk -F '"' '{print $4}' }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment