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 > Deleting files that are older than 5 days

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-04-08, 21:35
P_db_user P_db_user is offline
Registered User
 
Join Date: Jul 2008
Posts: 14
Deleting files that are older than 5 days

Hi All,

Can you please let me know how to delete files in ksh that are older than 5 days

find <dir> -type f -mtime +5 -exec rm -f {} \;

I executed the above today it deletes the files created on 28th and not the files created on 30th.

Thanks in advance for your responses.

Regards,
P_db_user
Reply With Quote
  #2 (permalink)  
Old 11-04-08, 23:20
P_db_user P_db_user is offline
Registered User
 
Join Date: Jul 2008
Posts: 14
The below is what I tried.

find . -type f \( -ctime +3 -o -ctime 3 \) -exec rm -f {} \;

If it is not correct can you please correct me

Regards,
P_db_user

Last edited by P_db_user; 11-05-08 at 23:34.
Reply With Quote
  #3 (permalink)  
Old 11-05-08, 01:54
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
man find
Code:
     ...
     Example 6: Selecting a File Using 24-hour Mode

     The descriptions of -atime, -ctime, and -mtime use the  ter-
     minology n "24-hour periods''. For example, a file accessed
     at 23:59 is selected by:

     example% find . -atime -1 print

     at 00:01 the next day (less than 24 hours  later,  not  more
     than one day ago). The midnight boundary between days has no
     effect on the 24-hour calculation.
     ...
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