To delete files older than 5 days from a directory, we can use command.
find /directory -type f -mtime +5 -delete
But, in my case, I want to delete only those files having 'YYYY-MM-DD' in their names and which are older than 5 days.
Below are some example of filenames:
TEST_2016-11-20_14_02_52.log server.log.2016-11-13 locsub.log.2016-12-04 wsgi.txt.2016-12-01
Only files having name in format 'YYYY-MM-DD' and older than 5 days should get deleted.
How to match filenames in find command using regex ??