As we know, to remove files we can use this safe option
find /path/to/directory/ -mindepth 1 -mtime +5 -delete
What if we want to remove both folders and files under /path/to/directory/ folder; what should be the syntax?
The delete option can't remove folders that are not empty.
find /var/tmp -type d -mindepth 1 -mtime +5 -delete find: warning: you have specified the -mindepth option after a non-option argument -type, but options are not positional (-mindepth affects tests specified before it as well as those specified after it). Please specify options before other arguments. find: cannot delete `/var/tmp/foreman-ssh-cmd-1b987fef-10ca-4204-bf4b-441f28a3db07': Directory not empty find: cannot delete `/var/tmp/foreman-ssh-cmd-2687d337-2b60-4f20-b581-a70807c22cb9': Directory not empty find: cannot delete `/var/tmp/foreman-ssh-cmd-faedbb3a-7756-4c96-8a40-a4a2001b5fb3': Directory not empty