Last active
August 29, 2015 14:26
-
-
Save mAu888/b6b6ff8b1b4186213725 to your computer and use it in GitHub Desktop.
Resolve (short) URLs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this into your `~/.bashrc` and `source ~/.bashrc` | |
function expandurl { | |
# -s Only output | |
# -I HEAD request | |
# -L Follow redirects. Combined with -I will print headers from all intermediate redirects | |
REDIRECTS=$(curl -sIL $1 | grep ^Location); | |
if [[ -z $REDIRECTS ]]; then | |
echo "Location: ${1}"; | |
else | |
echo "$REDIRECTS"; | |
fi | |
} | |
# Example | |
# | |
# $ mau:~> expandurl goo.gl/dUV6Su | |
# Location: http://www.mauriciohanika.de/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment