invcsplit.sh

 



if [ $# -lt 1 ]; then
   echo "Usage: invcsplit.sh filename.xml"
   exit 1
else
   inputfile=$1
fi

date

perl /usr/local/bin/invcsplit.pl $inputfile

head -14 $inputfile  > head.xml
tail -3 $inputfile  > tail.xml

exc=`ls -1 [0-9]$inputfile | wc -l`
ctr=1
for i in `ls [0-9]$inputfile`
do
    echo $i
    if [ $ctr -gt 1 ]
    then
        cat head.xml  > $i.tmp
    fi
    cat $i >> $i.tmp
    if [ $ctr -lt $exc ]
    then
        cat tail.xml >> $i.tmp
    fi
    mv $i.tmp $i
    ctr=`expr $ctr + 1`
done


### Remove the CheckSum from the last file
sed "/<CheckSum>/,/<\/CheckSum>/d" $i > $i.tmp
mv $i.tmp $i

    
date