#!/bin/bash
# Must be run from output dir

N_LOAD=/home/alanh/niagara-ws/niagara_3/brutus/load
N_LOAD=/local.lusitania.3/bolo/ws/niagara_3/brutus/load
N_LOAD=/local.e-fitz.4/bolo/ws/niagara_3/brutus/load

cd /common/tmp/bolo/output

ALL=PART
ALL="PART CUSTOMER PARTSUPP ORDERS LINEITEM NATION REGION SUPPLIER"
if [ $# -gt 0 ] ; then
	ALL="$*"
fi

for basedir in $ALL
do
	exec >${basedir}.xml

	echo '<'$basedir'S>'
	
	echo ==================================== $basedir 1>&2
	cd $basedir
	for subdir in `echo ${basedir}? ${basedir}?? ${basedir}???`
	do
		## oops, no matches for that one
		oops=`expr "$subdir" : "${basedir}?"`
		if [ $oops -gt 0 ] ; then
			continue
		fi
		echo ================ $basedir / $subdir 1>&2
		cd $subdir
		if [ "$subdir" = "$basedir"0 ] ; then
			echo ===== $basedir / $subdir special 0 1>&2

			for files in `echo ${basedir}?.xml ${basedir}??.xml ${basedir}???.xml`
			do
				## oops, no matches for that one
				oops=`expr "$files" : "${basedir}?"`
				if [ $oops -gt 0 ] ; then
					continue
				fi
				cat $files
			done
		else
			cat *.xml
		fi
		cd ..
	done	
	echo '</'$basedir'S>'
	cd ..
done
