The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 04-05-2004
philip_dba philip_dba is offline
Registered User
  
 

Join Date: Apr 2004
Location: Sydney
Posts: 1
Question 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0