Quantcast
Channel: Linux and Mac Hacks
Viewing all articles
Browse latest Browse all 39

Linux & Mac: Remove files older than a certain date

$
0
0
You can use the following code to remove files older than a certain date:

find /path/to/files/* -mtime +numdays -exec rm {} \;

Replace /path/to/files with the directory you want to scan, and numdays with a number (files older than numdays ago will be deleted). For example to clear your temp directory and only keep files from the last 7 days you could use:

find /tmp/* -mtime +7 -exec rm {} \;

Viewing all articles
Browse latest Browse all 39

Latest Images

Trending Articles





Latest Images