#!/bin/bash# Expects $1 to be a (speedtest1 --script) output file. Output is a# series of SQL files extracted from that file.infile=${1:?arg = speedtest1 --script output file}testnums=$(grep -e'^-- begin test'"$infile"|cut -d'' -f4)if[ x ="x${testnums}"];thenecho"Could not parse any begin/end blocks out of $infile"1>&2exit 1fiodir=${infile%%/*}if["$odir"="$infile"];thenodir=".";fi#echo testnums=$testnumsfor n in$testnums;doofile=$odir/$(printf"speedtest1-%03d.sql"$n)sed -n -e"/^-- begin test $n /,/^-- end test $n\$/p"$infile>$ofileecho-e"$n\t$ofile"done