I am aware of find -mtime +x -delete
, but how do I use it - or use it in a script - in order to delete all the "old stuff" (including hidden files) ?
Eg, if I have a dir target_dir
:
- delete all folders and subfolders of
target_dir
whose content in any deep level has not changed by X days (i.e. delete old directory tree branches) - delete all the files in
target_dir
that didn't change by X days
Edit: related to this topic but the accepted answer there doesn't really work, because by first removing files we "update" the modification date of the old directories so that they are not removed in the second step... also not sure about possible hidden files/directories..