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