-
-
Save mathieu-aubin/16afd0f39bb33b96c280a35a850fa233 to your computer and use it in GitHub Desktop.
Simple script that prints a list of redirects, and what the final HTTP result was...
This file contains hidden or 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
function count_redir { | |
curl -L -I -D - -o /dev/null $1 | awk 'BEGIN { redir = 0; status = 200; } tolower($1) ~ /http/ { redir=redir+1; status=$2 } tolower($1) ~ /location:/ { print redir, status, $2 } END { print "Completed, with ", redir-1, "redirects. Final result: ", status }' | |
} |
This file contains hidden or 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
alexandra:~ xistence$ count_redir http://slate.me/1h0svt8 | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
0 120 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 | |
0 101 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 | |
0 120 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 | |
0 101 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 | |
0 120 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 | |
0 95 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 | |
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 | |
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0 | |
1 301 http://slate.trib.al/8OfbdvM | |
2 301 http://slate.me/1tByJQz | |
3 301 http://slate.trib.al/IOYnwof | |
4 301 http://slate.me/1kZ76jq | |
5 301 http://slate.trib.al/QjWEhrI | |
6 301 http://goo.gl/qF0xUk | |
7 301 http://www.slate.com/blogs/future_tense/2014/05/30/nyc_citi_bike_zero_fatalities_in_new_york_city_bike_share_program_s_first.html | |
Completed, with 7 redirects. Final result: 200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment