Delete files older than another file

Using the find command in *nix is very useful. You can specify that you would like to find files newer than another file, or older or newer than a certain time. You cannot (directly) find files older than another file. However, there is a simple step that allows you to do this.

Simply add the negation operator (!) to the find -newer switch, and it will everything outside of what that set returns. In other words, it returns files older than the file you pass.

find . ! -newer your_file_timestamp_you_are_checking.txt

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.