12cae138fSstephan#!/bin/bash 22cae138fSstephan# Expects $1 to be a (speedtest1 --script) output file. Output is a 32cae138fSstephan# series of SQL files extracted from that file. 42cae138fSstephaninfile=${1:?arg = speedtest1 --script output file} 52cae138fSstephantestnums=$(grep -e '^-- begin test' "$infile" | cut -d' ' -f4) 649a785faSstephanif [ x = "x${testnums}" ]; then 749a785faSstephan echo "Could not parse any begin/end blocks out of $infile" 1>&2 849a785faSstephan exit 1 949a785faSstephanfi 10*fbf0f488Sstephanodir=${infile%%/*} 11*fbf0f488Sstephanif [ "$odir" = "$infile" ]; then odir="."; fi 122cae138fSstephan#echo testnums=$testnums 132cae138fSstephanfor n in $testnums; do 14*fbf0f488Sstephan ofile=$odir/$(printf "speedtest1-%03d.sql" $n) 1549a785faSstephan sed -n -e "/^-- begin test $n /,/^-- end test $n\$/p" $infile > $ofile 162cae138fSstephan echo -e "$n\t$ofile" 172cae138fSstephandone 18