#!/bin/sh # Clean up from any previous runs. rm -f henryrec.sql all-completable-lists.js *.out for name in chamber opera orchestral song; do \ ./xml_to_sql.py \ --completable-kinds="composer,title,conductor,orchestra,soloist,accompanist,hall,nationality" \ < ${name}.xml >> henryrec.sql done # TODO: See https://iridakos.com/how-to/2019/05/16/\ # remove-duplicate-lines-preserving-order-linux.html # for a possibly better way to do this in awk. TL;DR: # # $ gawk '!visited[$0]++' your_file > deduplicated_file for name in composer title conductor orchestra soloist accompanist hall nationality; do cat ${name}.out | sort | uniq > ${name}.out.tmp mv ${name}.out.tmp ${name}.out gawk -- '{ print "\"" $0 "\"," }' ${name}.out > ${name}.out.tmp mv ${name}.out.tmp ${name}.out echo "var ${name}List = [" > ${name}-list.js cat ${name}.out >> ${name}-list.js truncate ${name}-list.js -s -2 echo "" >> ${name}-list.js echo "];" >> ${name}-list.js echo "" >> ${name}-list.js # Add it to the growing list-of-lists. cat ${name}-list.js >> all-completable-lists.js echo "" >> all-completable-lists.js done