Celeb Glow
updates | March 22, 2026

How to remove only files created before a specific date and time

l would like to remove from my directory files which have been created before 04/29/2018 at 4:00 pm.

Thank you

1 Answer

Linux doesn't keep record of creation time, there are only 3 time records for files: last access, last modification of contents and last modification of the inode. So you are left with 3 options:

To delete all files modified before 04/29/2018 at 4:00 pm:

find . -type f ! -newermt '04/29/2018 16:00:00' -exec rm -f {} \;

To delete all files accessed before 04/29/2018 at 4:00 pm:

find . -type f ! -newerat '04/29/2018 16:00:00' -exec rm -f {} \;

To delete all files which had their permission changed before 04/29/2018 at 4:00 pm:

find . -type f ! -newerct '04/29/2018 16:00:00' -exec rm -f {} \;

You probably wouldn't want to run the above commands as root, and remember to backup any important files.

Important note!

You should treat date values with caution. Even though I did a complete format to my hard drive last month, I have some files in my home directory dating back to 2014!

Sources: [1][2][3]

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy