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
10#echo testnums=$testnums
11for n in $testnums; do
12  ofile=$(printf "speedtest1-%03d.sql" $n)
13  sed -n -e "/^-- begin test $n /,/^-- end test $n\$/p" $infile > $ofile
14  echo -e "$n\t$ofile"
15done
16