diff options
-rwxr-xr-x | title.bash | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -39,6 +39,12 @@ then else eval curl $OPTS -D /tmp/$TIME.header '$url' -o /tmp/$TIME.body.gz grep -q "Content-Encoding: gzip" /tmp/$TIME.header && gunzip /tmp/$TIME.body.gz || mv /tmp/$TIME.body.gz /tmp/$TIME.body - awk -vRS="</title>" '/<title>/{gsub(/.*<title>|\n+/,"");print;exit}' IGNORECASE=1 /tmp/$TIME.body | sed ':a;N;$!ba;s/\n//g' | sed -e 's/^[ \t]*//' + grep -q "Content-Type: text/plain" /tmp/$TIME.header && TYPE="text/plain" + if [ "$TYPE" == "text/plain" ] + then + head -n1 /tmp/$TIME.body + else + awk -vRS="</title>" '/<title>/{gsub(/.*<title>|\n+/,"");print;exit}' IGNORECASE=1 /tmp/$TIME.body | sed ':a;N;$!ba;s/\n//g' | sed -e 's/^[ \t]*//' + fi rm /tmp/$TIME.header /tmp/$TIME.body fi |