#!/bin/sh
# the only optional parameter is the list of the files to break 


SPLITDIR=src

if test "${1}set" = set ; then
echo "Please specify files to split!"
exit 1
fi

GROUPED=$*
echo $GROUPED
# we have to clean the directory because some deleted group may stay there
rm -f $SPLITDIR/*.koi
rm -f $SPLITDIR/*.koi.err
for words in $GROUPED ; do
	_words=`basename ${words} .koi`
	grep -v '/' < $words > $SPLITDIR/${_words}.0.koi
	for flag in `sed -n 's/^.*\/\(.*\)$/\1/p' < $words | sort | uniq` ; do
	    grep "/$flag$" < $words > $SPLITDIR/${_words}.${flag}.koi
	done
done


