#!/bin/sh if [ ! "$#" = 1 ] then echo "Usage: $1 NGINX-LOG-FILE" exit 1 fi set -e sample="$1" items="gtk%2B-3 glib-2 coreutils-8 python-3 r-minimal-[34] openmpi-4 hwloc-2 gfortran-7" for i in $items do # Tweak the regexp so we don't catch ".drv" substitutes as these # usually compress better with gzip. lzip="$(grep -E "/lzip/[[:alnum:]]{32}-$i\\.[[:digit:]]+(\\.[[:digit:]]+)? " < "$sample" | wc -l)" gzip="$(grep -E "/gzip/[[:alnum:]]{32}-$i\\.[[:digit:]]+(\\.[[:digit:]]+)? " < "$sample" | wc -l)" echo "$i: gzip/lzip ratio: $gzip/$lzip $(($gzip * 100 / $lzip))%" done