#!/bin/bash read url arg1=`echo "$url" | cut -d\ -f1` argrest=`echo "$url" | cut -d\ -f1 --complement` if [[ $arg1 = "--version" ]] then echo "Blatech head v0.2" exit elif [[ $arg1 = "-h" || $arg1 = "--help" ]] then echo "Give an HTTP URL to get its MIME type, size and modified date. -v for verbose output, --help for this help message, --version for the version number." exit elif [[ $arg1 = "-v" ]] then curl -sI "$argrest" | sed ':a;N;$!ba;s/\r\n/ | /g' | sed 's/ | \r$//' exit fi curl -sI "$url" > head.txt 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` length=`grep Content-Length head.txt | cut -d " " -f2 | ./filesize.sh | sed -r "s/[ \t]{2,}//"` if [[ ! "$http" =~ "200" ]] then echo $http else if [ -z "$length" ] && [ -z "$modified" ] then echo "$type" else echo "$type | $length | $modified" fi fi rm head.txt