Not Just Paranoid

Another site by Pete Maynard

Delete files based on last modified date

First create some files to test with:

 touch -d 01/01/2015 newfile
 touch -d 01/01/2009 oldfile

Check it worked. using ls -l

osaka@rika:~/test$ ls -l
total 0
-rw-r--r-- 1 osaka osaka 0 Jan  1  2015 newfile
-rw-r--r-- 1 osaka osaka 0 Jan  1  2009 oldfile

And now delete all files which where last modified over one year ago.

find . -mtime +360 -delete

The same as;

find /home/osaka/test/ -mtime +360 -exec rm '{}' \;

Enojy.

3 Oct 2011 | Tags ( find Linux ls touch )

Website Last Updated on 15 Sep 2023 (CC BY-SA 4.0)

This site uses JQuery and nanogallery2 hosted by jsdelivr.net
for the Flickr photo feed and GoatCounter for user insights.