Theodore Baschak

BOFH. Open Source Guru. Founder/Operator of Hextet Systems, AS395089 and Network Architect for Daemon Defense Systems, AS55101.

Unshortening with cURL

Tue, 12 Aug 2014 21:47:34 -0500 » Nerd Projects, Networking, CLI, System Administration, Network Monitoring

Sometimes you get a short URL for something and would like to know where it goes before clicking on it. cURL can help you determine this. This can be done with the following one-liner.

curl -s -o /dev/null -I -w "%{url_effective}\n" -L $URL

This can be adapted into a simple, small shell script which gives the user a usage/help when 1 argument isn’t given.

function usage ()
echo "Usage:";echo " $0 <url>"
if [ $# -ne 1 ]; then
usage;exit 127
curl -s -o /dev/null --head -w "%{url_effective}\n" -L "$1"
© Theodore Baschak - - Powered by Jekyll.
Powered by is a personal website. Opinions expressed are not necessarily those of his employer.