script to read configuration file

Hi,

I would like to write a Korn shell script which will remove files older than a certain date. In my script, it will read a configuration file with the following entries:

# <directory> <filename wildcard>
#
/home/philip/log .log
/home/philip/log1 delete-me
.log

The cleanup script will then process the configuration file line by line and read the directory path (DIRPATH) and filetype (FILETYPE).

Then i will have a find statement

find $DIRPATH -name $FILETYPE -mtime +7 -exec /bin/rm \{} \;

Below is the code segment:

cat $CONFIG | while read LINE
do
case $LINE in
\#*) ;;
'') ;;
*)
mydir="`echo $LINE | awk '{ print $1 }'"
filetype="`echo $LINE | awk '{ print $2 }'"
if [ -z $mydir ] || [ -z $filetype ]; then
echo "empty values for directory or file type"
exit 1
fi
find $mydir -name $filetype -mtime +${PURGE_DAYS} -exec /bin/rm \{} \;

            ;;
    esac                                     

When i run the script, at the time when it read the configuration file, it expanded the filetype variable to (1.log 2.log 3.log etc). when the program got to the find command , it just failed.

How do i make it to store *.log in the filetype variable so that i could pass it to find command?

Thanks in advance

philip

Let ksh do more of the work. Try:

exec < $CONFIG

while read mydir filetype ; do
case $mydir in

etc