The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need help with complicated script (reading directories, extracting data) Gill Bates Shell Programming and Scripting 3 02-20-2007 07:05 PM
Clean File kris01752 UNIX for Advanced & Expert Users 5 09-28-2006 10:40 AM
Clean Text File kris01752 UNIX for Advanced & Expert Users 1 08-24-2006 02:48 PM
Clean file in single action djp Shell Programming and Scripting 1 06-19-2006 05:34 PM
Reading file names from a file and executing the relative file from shell script anushilrai Shell Programming and Scripting 4 03-10-2006 05:25 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-22-2008
max_payne1234 max_payne1234 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 7
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 (permalink)  
Old 08-22-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
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 (permalink)  
Old 08-23-2008
max_payne1234 max_payne1234 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 7
Thanks a ton!! let me try it ..wil get back to you with latest
Sponsored Links
Closed Thread

Bookmarks

Tags
awk, clean, directory, grep, grep in solaris

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 07:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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