Gnuru.org
Productive Linux


Subscribe

 Subscribe via Feedburner in a reader

Enter your email address:

Delivered by FeedBurner


Login
Login:
Password:



Don't have an account?
Sign up to Gnuru.org
Forgot your password?

Delete files older than a certain date
17 April 2012 @ 12:12 BST
by Paul

Here is a script to clean up a directory, by deleting files older than a certain date:

#!/bin/bash

DIR=~/Download/

# delete files older than 7 days

find $DIR -mtime +7 -exec rm '{}' \;

# delete empty directories

find $DIR -depth -type d -empty -exec rmdir '{}' \;



Comments disabled