view bin/clm.sh @ 143:ddff993994be

too clever by half, keys won't work in parallel for e.g. media types
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Wed, 20 Oct 2021 15:47:55 +0000
parents d3ef00af2064
children
line wrap: on
line source

#!/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"