Skip to content

Instantly share code, notes, and snippets.

@sdball
Created August 8, 2012 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdball/3294980 to your computer and use it in GitHub Desktop.
Save sdball/3294980 to your computer and use it in GitHub Desktop.
Expand URLs by following a single redirect
#!/bin/bash
main() {
if [ -z $1 ]; then
echo "Usage: expand-url URL"
exit 1
fi
url=$1
response $url | parse_redirect
}
response() {
wget --max-redirect=0 -S $url 2>&1
}
parse_redirect() {
ack "http.* " -o
}
main $1
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment