|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Deleting files older than a given date
Hi all,
I want to delete all files in a directory which are older than a given date. I thought of doing it by creating a file by the required date by using touch command. And then i would use find command on that file and try to find files older than that. I searched the man and found a newer option for find command. But i didn't get the opposite of it (i would like to find older files) Can anyone please tell me the easiest way to do that? Thanks in advance, raju |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Read your "find" man page carefully and see if "-mtime +3" is the opposite of "-mtime -3". It is in some newer versions of find, and you may have one.
This is a case where posting the result of "uname -sr" or something similar would allow those with specialized knowledge to help more. |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
you could use the find command
eg find /my_current_directory -mtime +5 -exec rm {} \; Note To find files created more than 5 days use -mtime +5 To find files created less than 5 days use -mtime -5 |
|
#4
|
||||
|
||||
|
Quote:
Code:
find /my_current_directory -mtime +5 -print | xargs rm I.e., invoke "rm" on large groups of files --- frequently only once. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Deleting files older than 6 hours | subhasri_2020 | Shell Programming and Scripting | 13 | 01-31-2011 02:16 PM |
| deleting files older than 7 days | MAYAMAYA0451 | Shell Programming and Scripting | 1 | 01-02-2011 11:49 PM |
| Deleting older files of a particular type | cmap | UNIX for Advanced & Expert Users | 6 | 09-30-2009 04:09 AM |
| Deleting files older than 7 days | shezam | Shell Programming and Scripting | 4 | 07-09-2008 04:40 AM |
| Deleting Files Older than 24 hours | mazhar803 | Solaris | 7 | 09-27-2007 07:30 AM |
|
|