write script for more then 600 files

Hi,
i have 600 or more file on my server and from this 600 files i want to make one file. i have written this script

SPATH=/etlstg/DAT
TPATH=/etlstg/DAT/DAT_PROCESSED
FILE_DATE=`TZ=CST+24 date +20%y%m%d`
a1=0
while [ $a1 -le 9 ]
do
a2=0
while [ $a2 -le 9 ]
do
a3=0
while [ $a3 -le 9 ]
do
a4=0
while [ $a4 -le 9 ]
do
cat $SPATH/dat$FILE_DATE_*_[$a1][$a2][$a3][$a4]* >> $TPATH/dat$FILE_DATE.txt

           a4=\`echo $a4\+1|bc\` 
           done
           a3=\`echo $a3\+1|bc\` 
         done
     a2=\`echo $a2\+1|bc\`   
     done

a1=`echo $a1+1|bc`
done

This script seems to work fine, but i m not able to validated it

I also want to maintain a log where i can enter the file count. can anyone help me to modify this script???

There is probably a much simpler way to do that task. But here is a slightly simplified way using the builtin capabilities of Bash.

#!/bin/bash
SPATH=/etlstg/DAT
TPATH=/etlstg/DAT/DAT_PROCESSED
FILE_DATE=`TZ=CST+24 date +%Y%m%d`
F=$TPATH/dat$FILE_DATE.txt

for ((a1=0;  a1<10;  a1++)); do
  for ((a2=0;  a2<10;  a2++)); do
    for ((a3=0;  a3<10;  a3++)); do
      for ((a4=0;  a4<10;  a4++)); do
        echo cat $SPATH/dat${FILE_DATE}_*_[$a1][$a2][$a3][$a4]* >> $F
      done
    done
  done
done

Notice that %Y is what you want instead of 20%y.

Once you are have verified that it does what you expect, remove echo, delete the output file and run it again.

Wait! Come to think of it, I think you could replace those 4 loops with this:

for ((a=0;  a<10000;  a++)); do
    echo cat $SPATH/dat${FILE_DATE}_*_"$(printf "%04d" $a)"* >> $F
done