Moving log files based on month - help with ksh shell script

Hello,

I'm trying to move the log files from the parent directory to respective monthly folder and I would be running this script on a weekly basis through cron.

I'm new to this scripting and here is what i could come up and it runs without really doing anything. I even tried placing echo statements for each of the case and still it does not do anything. Any help is greatly appreciated. When i just run this directly, i do get the listing of the month in 3 letters for all the log files in the folder.

#! /bin/ksh

for file in /test/logs ;
do
month=$(ls -l $file | awk '{ print $6 }')

case "$month" in
    "Jan") mv $file /test/logs/Jan/$file ;;
    "Feb") mv $file /test/logs/Feb/$file ;;
    "Mar") mv $file /test/logs/Mar/$file ;;
    "Apr") mv $file /test/logs/Apr/$file ;;
    "May") mv $file /test/logs/May/$file ;;
    "Jun") mv $file /test/logs/Jun/$file ;;
    "Jul") mv $file /test/logs/Jul/$file ;;
    "Aug") mv $file /test/logs/Aug/$file ;;
    "Sep") mv $file /test/logs/Sep/$file ;;
    "Oct") mv $file /test/logs/Oct/$file ;;
    "Nov") mv $file /test/logs/Nov/$file ;;
    "Dec") mv $file /test/logs/Dec/$file ;;
    *) echo " Do nothing " ;;
esac
done

Thanks

see 'man ls' under the --time-style. you can use the +FORMAT to specify the time format you like. In your case, it wiil be --time-style=+%b

cd /test/logs
mkdir Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
ls -l --time-style=+%b | while read perm size user group byte month filename
do
  if [ -f "$filename" ]; then
    mv "$filename" $month
  fi
done

Thanks for showing me to how to in much simpler way. However, i'm getting an error when i ran your script. The error is

ls: illegal option -- time-style=+%b
usage: ls -1RaAdCxmnlhogrtuvVcpFbqisfHLeE@ [files]