From 4dd62f4540210e2143497943c5c51062c57cd73e Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Mon, 4 Aug 2014 11:32:49 +0100 Subject: Add support for detailing HTTP 301/302 redirects --- head.bash | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/head.bash b/head.bash index aa27d80..9b0881d 100755 --- a/head.bash +++ b/head.bash @@ -18,7 +18,7 @@ argrest=`echo "$url" | cut -d\ -f1 --complement` if [[ $arg1 = "--version" ]] then - echo "Blatech head v0.2.2" + echo "Blatech head v0.3" exit elif [[ $arg1 = "-h" || $arg1 = "--help" ]] then @@ -36,10 +36,14 @@ sed -i ':a;N;$!ba;s/\r//g' head.txt http=`grep HTTP head.txt` modified=`grep Last-Modified head.txt | sed "s/Last-Modified: //"` type=`grep Content-Type head.txt | cut -d " " -f2` +location=`grep Location head.txt | cut -d " " -f2` length=`grep Content-Length head.txt | cut -d " " -f2` length=`filesize $length | sed -r "s/[ \t]{2,}//"` -if [[ ! "$http" =~ "200" ]] +if [[ "$http" =~ "301" || "$http" =~ "302" ]] +then + echo "$http to $location" +elif [[ ! "$http" =~ "200" ]] then echo $http else -- cgit v1.2.3