expoweb/noinfo/scripts/loser-caves1624-raw-data/split.sh

27 lines
516 B
Bash

#!/bin/bash
set -eu -o pipefail
mkdir -p split
file=split/start.svx
kat=
while read line; do
line=$(echo $line | sed 's/\t/ /g')
line=$(echo $line | sed 's/ / /g')
s=$(echo $line | sed 's/^\*begin \([0-9]*\)$/\1/')
if [ "$s" == "$line" ]; then
echo "$line" \
| egrep -q -m 1 '^\*end [0-9]+$' \
|| (echo "$line" >> $file)
else
echo ">>$line<<"
echo ">>$s<<"
echo "*end $kat" >> $file
file=split/$s.svx
kat=$s
echo "Starting $kat"
echo "*begin $kat" > $file
fi
done