#!/bin/sh rm -f upenn/*.imp for i in upenn/* do BOOK=$(grep " 1:1" $i|cut -f1 -d' ') echo "Book: $BOOK" echo "\$\$\$$BOOK 0:0" > $i.imp # These are mostly for very strange things in Hermes, which seems to include # Muliple reference systems which start chapters over after main sections # But also include a chapter numbering scheme which doesn't start over # so for now, we're choosing that one. sed "s/:heading$/:0/" $i \ |sed s/prologue:1/1:0/ \ |sed "s/^$BOOK\\(.*[0-9]\\)$/\$\$\$$BOOK\\1/" \ |sed "s/\\(\$\$\$[^ ]* \\)[0-9]*\\[\\([0-9]*\\)0\\^/\\1\\21/" \ |sed "s/\\(\$\$\$[^ ]* \\)[0-9]*\\[\\([0-9]*\\)1\\^/\\1\\22/" \ |sed "s/\\(\$\$\$[^ ]* \\)[0-9]*\\[\\([0-9]*\\)2\\^/\\1\\23/" \ |sed "s/\\(\$\$\$[^ ]* \\)[0-9]*\\[\\([0-9]*\\)3\\^/\\1\\24/" \ |sed "s/\\(\$\$\$[^ ]* \\)[0-9]*\\[\\([0-9]*\\)4\\^/\\1\\25/" \ |sed "s/\\(\$\$\$[^ ]* \\)[0-9]*\\[\\([0-9]*\\)5\\^/\\1\\26/" \ |sed "s/\\(\$\$\$[^ ]* \\)[0-9]*\\[\\([0-9]*\\)6\\^/\\1\\27/" \ |sed "s/\\(\$\$\$[^ ]* \\)[0-9]*\\[\\([0-9]*\\)7\\^/\\1\\28/" \ |sed "s/\\(\$\$\$[^ ]* \\)[0-9]*\\[\\([0-9]*\\)8\\^/\\1\\29/" \ |sed "s/\\(\$\$\$[^ ]* \\)[0-9]*\\[104_/\\1106/" \ |sed "s/\\(\$\$\$[^ ]* \\)[0-9]*\\[104\`/\\1107/" \ |sed "s/\\(\$\$\$[^ ]* \\)[0-9]*\\[104a/\\1108/" \ |sed "s/\\(\$\$\$.* \\)[0-9]*\\[\\(.*\\)\\]y/\\1\\2/" \ |sed "s/\\(\$\$\$.* \\)[0-9]*\\[\\(.*\\)\\]/\\1\\2/" \ >> $i.imp done