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