Bdfy
Bdfy

Reputation: 24621

Recursively delete files in directory

How do I recursively delete files in directory that were modified more than 6 hours ago?

This example work for 1 day:

find /data2/input -type f -mtime +1 -delete -print

Upvotes: 1

Views: 558

Answers (2)

norq
norq

Reputation: 1434

Use -mmin instead of mtime. It will allow you to specify the number of minutes since the files was last modified. So for files older than 6 hours:

find /data2/input -type f -mmin +360 -delete -print

Upvotes: 3

Some programmer dude
Some programmer dude

Reputation: 409146

Check the flags -cmin or -mmin in the manual page.

Upvotes: 1

Related Questions