Was bored today, this is for you linux users that want to create and decode links using the goo.gl url shortener service.
Code:
#!//bin/bash
# goo.gl link creator and decoder
case "$1" in
create)
if [ $# -ne 2 ]
then
echo "url to shorten needed."
exit
fi
curl -s -d "url=${2}" http://goo.gl/api/url | sed -n "s/.*:\"\([^\"]*\).*/\1/p";
;;
decode)
if [ $# -ne 2 ]
then
echo "url to decode needed"
exit
fi
check=$(echo $2 | sed -n 's/.*\(http:\/\/goo.gl\/[A-Za-z0-9][A-Za-z0-9]*\).*/\1/p');
if [ -n "$(echo $check)" ]; then
curl -sI $2 | sed -n 's/Location:.* //p';
else
echo "you must give a valid goo.gl link"
fi
;;
*)
echo "Usage: `basename $0` {create|decode}" >&2
exit 64
;;
esac
also posted it on pastebin
http://pastebin.com/bx8zYRUV
enjoy ;)
