simple scripting question
i have several dirs and i want to delete the ones that are older than 60 days.
currently im doing it like this:
find /path/backups-* -type d -mtime +60 | xargs rm -r
but i dont want to go through the CONTENTS of the dirs and delete every individual file that is older than 60d. i want to either delete or not delete the whole dir depending on its timestamp.
but i only know of find that accepts something as spiffy as -mtime +60, and i cant find any options for it like "--non-recursive".
any suggestions?
basically this is for removing outdated backups.
Quoted 11 lines · urgrue
i have several dirs and i want to delete the ones that are older than 60 days.
currently im doing it like this:
find /path/backups-* -type d -mtime +60 | xargs rm -rbut i dont want to go through the CONTENTS of the dirs and delete every individual file that is older than 60d. i want to either delete or not delete the whole dir depending on its timestamp.
but i only know of find that accepts something as spiffy as -mtime +60, and i cant find any options for it like "--non-recursive".
find <dirs> -type d -mindepth 1 -maxdepth 1
will find exactly those directories whose parent is one of <dirs>.
Signature · 1 line
Glynn Clements <[email protected]>
Quoted 5 lines · urgrue
i have several dirs and i want to delete the ones that are older than 60 days.
currently im doing it like this:
find /path/backups-* -type d -mtime +60 | xargs rm -r
Quoted 7 lines
but i dont want to go through the CONTENTS of the dirs and delete every individual file that is older than 60d. i want to either delete or not delete the whole dir depending on its timestamp.
but i only know of find that accepts something as spiffy as -mtime +60, and i cant find any options for it like "--non-recursive".
Why cannot you use -maxdepth 0 option?
liana:~$ man find
[...]
-maxdepth levels
Descend at most levels (a non-negative integer) levels of
directories below the command line arguments. `-maxdepth 0'
means only apply the tests and actions to the command line
arguments.
[...]Mikhail