If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > using the find Command

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-08-05, 14:59
faithinu faithinu is offline
Registered User
 
Join Date: Jul 2005
Posts: 7
using the find Command

Hello again. This time i am trying to use the find command to lookup files that are older than 180days and then remove them. I am having trouble with it.

Here is what i have:

find /directory -atime +10?? -exec rm -f {} \;
?? not sure what to put there.
Reply With Quote
  #2 (permalink)  
Old 11-08-05, 16:07
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,454
May be "42"?
Reply With Quote
  #3 (permalink)  
Old 11-08-05, 20:56
faithinu faithinu is offline
Registered User
 
Join Date: Jul 2005
Posts: 7
very cute.. No really its like i can not think or something

I know i want to use the find command followed by the directory path and i know that i want to execute the remove command but i can figure out how to check which files are 180 day old. File structure looks like example: tmp.20040904.log
Reply With Quote
  #4 (permalink)  
Old 11-09-05, 01:24
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
Is there a direct relationship between the file name and the modification time (mtime +180)?
e.g. Can you create a file today with a file name of last week and than do you want to check on the date in the file name?
If yes you’ll have to strip off the date from the filename
Then do some date calculations
or use the stripped filename as input to the touch command to sync the modification time with the filename before executing find.
Reply With Quote
  #5 (permalink)  
Old 11-09-05, 12:14
yrs yrs is offline
Registered User
 
Join Date: Nov 2005
Posts: 2
find /directory -mtime +180 -exec rm -f {} \;

this will delete all files in the directoy older than 180 days is this your requirement?
Reply With Quote
  #6 (permalink)  
Old 11-10-05, 10:44
faithinu faithinu is offline
Registered User
 
Join Date: Jul 2005
Posts: 7
Thanks for the replys when i read the definition for mtime it just did not seem to apply. I went ahead an did it one at a time.. I had to get it done then but it is nice to know what to do next time it happens.. Thanks for your responces as always every one here is very nice and always helpful. I only hope someday i will know enough to help others as well..
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On