1#!/bin/bash 2# Expects $1 to be a (speedtest1 --script) output file. Output is a 3# series of SQL files extracted from that file. 4infile=${1:?arg = speedtest1 --script output file} 5testnums=$(grep -e '^-- begin test' "$infile" | cut -d' ' -f4) 6if [ x = "x${testnums}" ]; then 7 echo "Could not parse any begin/end blocks out of $infile" 1>&2 8 exit 1 9fi 10odir=${infile%%/*} 11if [ "$odir" = "$infile" ]; then odir="."; fi 12#echo testnums=$testnums 13for n in $testnums; do 14 ofile=$odir/$(printf "speedtest1-%03d.sql" $n) 15 sed -n -e "/^-- begin test $n /,/^-- end test $n\$/p" $infile > $ofile 16 echo -e "$n\t$ofile" 17done 18