#! /bin/sh



#AbsolutePath="/home/tim/share/Web/public/Plugin/StepProcess/html";
AbsolutePath="/app/Web/public/Plugin/StepProcess/html";
#AbsolutePath=`pwd`"/public/Plugin/StepProcess/html";
TotalFile="FunctionWizard.html";

rm -rf $AbsolutePath"/FunctionWizard.html";

cat $AbsolutePath"/FunctionWizard/Basis.html" | sed 's/<\/select><\/div><\/div><\/div>//g' >> $AbsolutePath"/FunctionWizard.html";

HeadFileArray=`ls $AbsolutePath"/FunctionWizard" | grep ".html" | grep "\-0-"`;
for HeadFile in $HeadFileArray
do
    echo `cat $AbsolutePath"/FunctionWizard/"$HeadFile | sed 's/<\/optgroup>//g'` >> $AbsolutePath"/FunctionWizard.html";
    Head1=`echo "$HeadFile" | awk -F'-' '{print $1}'`;
    FileArray=`ls $AbsolutePath"/FunctionWizard" | grep ".html" | grep -v "\-0-" | grep -v "Basis.html" |   sort -t'-' -k1,1 -k2,2 -n`;
    for File in $FileArray 
    do
        Head2=`echo "$File" | awk -F'-' '{print $1}'`;
        if [ "$Head1" -eq "$Head2" ]; then
            echo $File;
            echo `cat $AbsolutePath"/FunctionWizard/"$File` >> $AbsolutePath"/FunctionWizard.html";
        fi
    done
    echo "</optgroup>" >> $AbsolutePath"/FunctionWizard.html";
done

echo "</select></div></div></div>" >> $AbsolutePath"/FunctionWizard.html";
