Last Updated: June 28, 2020
·
1.61K
· malte70

Decrypt shortened URL, the minimal way

Sometimes, you want to see which URL is behind a shortened link, without visiting the site.

If so, you might simply use a HEAD request with curl (http://mcbx.de/2b is the example URL):

$ curl -s -I http://mcbx.de/2b | grep '^Location' | cut -d" " -f2
https://coderwall.com/maltebublitz

Or, using awk instead of grep and cut:

$ curl -s -I http://mcbx.de/2b | awk '/^Location/ { print $2 }'

1 Response
Add your response

Leverage your curl-fu better!

curl -sIw '%{redirect_url}\n' http://bit.ly/XyProblem | tail -1

Ref: http://curl.haxx.se/docs/manpage.html#-w

over 1 year ago ·