![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help required with a Csh script to read data from a file | fizzme | Shell Programming and Scripting | 1 | 05-29-2008 08:30 PM |
| Shell script that reads from configuration file to get database | dolo21taf | Shell Programming and Scripting | 1 | 04-15-2008 08:47 PM |
| How to read the configuration file from shell script | nishanth hampal | Shell Programming and Scripting | 7 | 02-27-2008 03:42 AM |
| Read from file as script parameter | vmaxx | Shell Programming and Scripting | 2 | 06-25-2005 11:30 AM |
| file read + unix script | vivekshankar | UNIX for Dummies Questions & Answers | 2 | 05-23-2005 04:18 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|