This article provides methods for deleting all files before a certain date in Linux.
Method
Every now and then administrators find themselves in a bind where they need to delete files older than a certain date. This is not a big deal in small numbers, but when faced with a directory containing 120,000+ files it can be overwhelming. Don't worry, the following command will do it for you. You will simply need to adjust the date depending on what you want to do.
Be careful using these commands as their is no way to “undelete” files in Linux. You would need to restore from a backup.
Here is the command:
ls -la | grep May | /usr/bin/tr -s ' ' | /usr/bin/cut -d ' ' -f9 | xargs rm
That will list all files from May of the current year and delete them. Remember, Linux will not show the year of the file if it is the current year. You can use this command 12 times (once per month) and delete all files from each month. The following will list all files from 2010 and delete them: