I need a command that deletes all files, folders and sub-folders that were not updated longer than 31 days. I tried this one
find . -mindepth 1 -mtime +31 -exec rm -rf "{}" \;
But if I have hierarchy like this
.
├── old_sub_folder1
└── old_sub_folder2
├── old_file
└── old_sub_folder3
└── new_file
where old_*
are old folders\files and new_file
is a new file.
This command will delete all contents. Because old_sub_folder2
date was not updated after new_file
was created.
I need a command that would not delete old_sub_folder2/old_sub_folder3/new_file