#!/usr/bin/bash
if [ $# -ne 1 ]
then
 echo "Usage:  clm.sh outfile
Reads from stdin, which should be a complete set of HTTP header lines,
and _appends_ either the value of the Last-Modified header or a blank
line to the specified output file.

In case of a set of headers containing more than one Last-Modified line,
that output still consists of a single line, with all the values,
separated by a semi-colon (;).

So the output always consists of exactly one line."
 exit 1
fi
egrep '^Last-Modified: ' | cut -f 2- -d ' ' | tr -d '\r' | { readarray -t a ; IFS=';' ; printf %s "${a[*]}" ; } >> "$1"
echo >> "$1"

