Clean directories by reading from file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Clean directories by reading from file
# 1  
Old 08-22-2008
Clean directories by reading from file

I have a file in following format
directory1=/out/log
purgedays1=4
extn1=log,out,txt
directory2=/clean/log
purgedays2=4
extn2=log,out

now i need need to create a script that reads this file and cleans all the files with the given extn from the given directory.
The catch here is that number of entries in the extn field may vary.
Please help!!
# 2  
Old 08-22-2008
a start
Code:
while read value
do
     eval $value
done < file
for ext in $(echo $extn1 | tr -s ',' ' ')
do
     find $directory1 -mtime -$purgedays1 -name \*."$ext" -exec rm -f  {} \;
done

# 3  
Old 08-23-2008
Thanks a ton!! let me try it ..wil get back to you with latest
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading multiple directories and file from them

Hello I'm making script for Dallas temperature sensors (DS1820). When a sensor is connected, it shows up as a directory in /sys/bus/w1/devices in format 10-xxxxxxx. Inside the directory is a file called w1_slave which holds the temperature in format t=xxxxx. Each sensor has unique... (2 Replies)
Discussion started by: Klipeti
2 Replies

2. Shell Programming and Scripting

reading filename in nested directories

Hi all, I have some directory structure as $ls -ltr drwxr-xr-x 1 mscprod us_msc 512 May 10 08:34 650 drwxr-xr-x 1 mscprod us_msc 512 May 10 08:51 652 drwxr-xr-x 1 mscprod us_msc 512 May 10 08:51 640 drwxr-xr-x 1 mscprod us_msc512 May 10 09:13 654 $ cd 650/ $ls fileabc.root and within... (7 Replies)
Discussion started by: emily
7 Replies

3. Shell Programming and Scripting

[SOLVED] help clean up file movement script

Hello Group, Once again another script hacked together from a few sources to try and suit my needs. This is to go through a /temp directory and for each ls entry ask which Dir of three I want it sorted. The script works but there are a few behaviors that are odd so I figured I'd ask for help... (2 Replies)
Discussion started by: dpreviti
2 Replies

4. UNIX for Dummies Questions & Answers

Reading only first record from the multipe directories

Hi All, I have a requirement, I had a parent directory Land under that we have sub directories Yesterday, Today and Tommorrow And we have a file test.txt under the above directories Yesterday, Today and Tommorrow The data in the file test.txt under Yesterday folder is ... (5 Replies)
Discussion started by: somu_june
5 Replies

5. UNIX for Dummies Questions & Answers

command to clean up file systems

As you will verify, I am a really naive user of AIX 5.1. As such I wonder if you could possibly let me know of a command or procedure I could use to automatically, globally and safely, remove all useless files from my machine. I'm not referring to my own files because I perfectly know which of them... (1 Reply)
Discussion started by: ahjchr
1 Replies

6. UNIX for Advanced & Expert Users

Unable to clean up file system

Hi, Has anyone ever encountered the following scenario: I am working on a SUN server with solaris 10 installed and veritas managing the filesystem. One of the file systems has become full: df -kh /ossrc/dbdumps Filesystem size used avail capacity Mounted on... (6 Replies)
Discussion started by: eeidel
6 Replies

7. Shell Programming and Scripting

Need help with complicated script (reading directories, extracting data)

Hi, people. I was searching script tutorials/examples and found this forum, and thought to ask for help, because there seems to be many wise people here. (Try to bare with me, I'm a Windows user, so this stuff is somewhat strange to me, OK? :rolleyes: ) Anyways, I need to create a script that... (3 Replies)
Discussion started by: Gill Bates
3 Replies

8. UNIX for Advanced & Expert Users

Clean File

BeginDate 07/01/06 End: 07/31/06 Cust: A02991 - Burnham 0002000 5,829,773 145.3 0009701 4,043,850 267.3 2005000 286,785.13 100.0 BeginDate 07/01/06 End: 07/31/06 Cust: A01239 - East Track PSE Index A 0009902 317,356.82 890.2 0020021 ... (5 Replies)
Discussion started by: kris01752
5 Replies

9. UNIX for Advanced & Expert Users

Clean Text File

HI, I have a file which comes from crystal reports in the below format. I need to clean the file so that i will only have the columns(deptid,empid,ename,sal) and the data below the column names. There is a bug in the repoting tool( we only see page1-1 for every department).The rundate change... (1 Reply)
Discussion started by: kris01752
1 Replies

10. Shell Programming and Scripting

Clean file in single action

What one finds challenging another finds simple... (HPUX B.11.11) I have a text file named something like 12345.dst that could look like this: DOG CAT NONE TEST CAT What I want to end up with is 12345.dst looking like this: CAT DOG TEST removing "NONE" should it be there and... (1 Reply)
Discussion started by: djp
1 Replies
Login or Register to Ask a Question