Skip to content

Instantly share code, notes, and snippets.

@moonexpr
Last active September 17, 2022 18:44
Show Gist options
  • Save moonexpr/c6f00e40d5a4a8c2a5cb7d4be32783bb to your computer and use it in GitHub Desktop.
Save moonexpr/c6f00e40d5a4a8c2a5cb7d4be32783bb to your computer and use it in GitHub Desktop.
curl_resolve: Resolves a URL unil it no longer redirects, dumps it's final URL.
#!/usr/bin/bash
if [[ $# < 1 ]]; then
echo "Resovles a URL unil it no longer redirects, dumps it's final URL."
echo "usage: curl_resolve <url>"
exit 2
fi
MAX_REDIRECTS=3
curl --max-redirs $MAX_REDIRECTS $1 -s -L -I -o /dev/null -w '%{url_effective}'
#vim: set sw=4 ts=4 et
@moonexpr
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment