Delete Files Created Before Date


Say you want to delete files in /var/lib/files created before 2022-01-01:

$ touch --date "2022-01-01" /tmp/from
$ find /var/lib/files -type f -not -newer /tmp/from -delete

Delete friles between a from and to date

Say you want to delete files only created created in 2020:

$ touch --date "2020-01-01" /tmp/from
$ touch --date "2021-01-01" /tmp/to
$ find /var/lib/files -type f -newer /tmp/from -not -newer /tmp/to -delete

Licensed under CC BY Creative Commons License ~ ✉ torstein.k.johansen @ gmail ~ 🐘 @skybert@hachyderm.io ~ 🐦 @torsteinkrause