Author Topic: unshorten - Expands a short URL & displays the original URL  (Read 2825 times)

hakerdefo

  • Posts: 525
    • View Profile
    • Looking at Linux through the Windows of Life
Short URLs can be a security risk. 'unshorten' is a simple bash script that displays the original link of a short URL. It doesn't depend on any third party service.

Code: [Select]
#!/bin/sh
echo ""
echo "Expands a short url & displays the original url."
echo ""
echo "Enter a short url: "
read input_variable
if long=$(curl -s -o /dev/null --head -w "%{url_effective}\n" -L "$input_variable"); then
echo "Original url -> $long"
else
echo "Sorry! Invalid url!"
fi


Save this script some where in your path with the name 'unshorten' and give it 'Execute' permission. Next time you come across a short URL, Don't blindly click-open it in your Browser or Mail Application, Run 'unshorten' from your terminal and enter the short URL when prompted and 'unshorten' will return the original URL.
More info on 'unshorten' can be found here,
unshorten
Cheers!!!
You Can't Always Git What You Want

VastOne

  •      v-ger
  • Posts: 4225
    • View Profile
    • VSIDO Community
Re: unshorten - Expands a short URL & displays the original URL
« Reply #1 on: June 08, 2015, 04:53:07 AM »
^ Very nice hakerdefo!  I have been looking for something just like this letely

I appreciate you sharing it
VSIDO      VSIDO FB       

    I dev VSIDO