System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

is it possible to delete files by DATE ?

SOLVED
Go to solution
Bruno Vilardo
Regular Advisor

is it possible to delete files by DATE ?

Hello all,

I wpuld like to know if it´s possible to delete files by date instead of name.

Thanks a lot

Bru
2 REPLIES
Emil L. Dragic
Occasional Advisor
Solution

Re: is it possible to delete files by DATE ?

Hi Bruno,

You can use "find" command to find and delete files older than certain date. E.g.

# find /user -ctime +3 -exec rm {} \;

will find and delete all files created more than three days ago under /user directory.

See man pages for find for more details about options.

Regards
Emil L. Dragic
Michael Schulte zur Sur
Honored Contributor

Re: is it possible to delete files by DATE ?

Hi Bruno,

as my predecessor said, find is the command of choice and info can be found in man pages.

You can search by modification time or access time of a file or by modification time of the inode of the file. This is:
mtime
atime
ctime
Time is in days and used with +,- or space.
+1 means 2days plus
-1 means less than 1day
1 means 1day.

greetings,

Michael