Linux Shell - Remove Folders older than n days

Revision as of 10:16, 23 August 2020 by Ardaut (talk | changes) (Created page with "Example: How to remove folders in the folder "/home/tmp" that are older than 10 days. Change the number ten to any number you like. <pre>find /home/tmp/* -mtime +10 -exec rm...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Example: How to remove folders in the folder "/home/tmp" that are older than 10 days. Change the number ten to any number you like.

find /home/tmp/* -mtime +10 -exec rm -r {} \;

The command that you want to execute for folder (that is found) is added with the argument "-exec".