Finding files older than a certain date

Sometime you may find that you need to files that are older than a certain date.

Let's say that you wanted to find an email from 2016, these Two simple bash command will achieve this for you.

touch --date "2017-01-01" /home/USER/2017-01-01.txt
find /home/USER/mail -type f -not -newer /home/USER/2017-01-01.txt
rm /home/USER/2017-01-01.txt

The first line is creating a file with a modified date by which you would like to search

The second line is specifying the folder in which you would like to search; In our example your mail folder

The last command is just to clean up after yourself.

Note: You will need to change the "USER" to your CPanel username.


  • 0 Users Found This Useful
Was this answer helpful?

Couldn't find what you are looking for?

Related Articles

Search files for lines containing a match to a given pattern

grep --include=wp\-config.php -rnw -C 0 '/home/' -e "WP_MEMORY_LIMIT"