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

~ /home 🏠 ~ talks 💬 ~ bash ~ craftsmanship ~ db ~ dongxi ~ emacs ~ escenic ~ iam ~ java ~ js ~ language ~ latex ~ ldap ~ life ~ linux ~ llm ~ mac-os-x ~ mt-foo ~ network ~ norsk ~ python ~ quotes ~ running ~ security ~ travel ~ unix ~ various ~ vcs ~ webdesign ~ windows ~ discoveries ~ cv 🧙 ~

Licensed under CC BY Creative Commons License ~ 📡 RSS feed ~ ✉ torstein.k.johansen @ gmail ~ 🐘 @skybert@hachyderm.io ~ 🎥 youtube.com/@skybert