File: split-speedtest1-script.sh

package info (click to toggle)
sqlite3 3.46.1-7
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 150,660 kB
  • sloc: ansic: 281,304; tcl: 19,550; javascript: 12,978; sh: 10,768; java: 8,151; makefile: 1,690; yacc: 1,644; cpp: 440; cs: 307; sql: 45
file content (17 lines) | stat: -rwxr-xr-x 615 bytes parent folder | download | duplicates (17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/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}" ]; then
  echo "Could not parse any begin/end blocks out of $infile" 1>&2
  exit 1
fi
odir=${infile%%/*}
if [ "$odir" = "$infile" ]; then odir="."; fi
#echo testnums=$testnums
for n in $testnums; do
  ofile=$odir/$(printf "speedtest1-%03d.sql" $n)
  sed -n -e "/^-- begin test $n /,/^-- end test $n\$/p" $infile > $ofile
  echo -e "$n\t$ofile"
done