find - Kote

Remove old files in bash using ‘find’

How to quickly remove old files or likely old log files using bash? Just a few lines in bash can solve it.
Firstly, list all files older than 7 days for required directory:

find /home/my-user/my-logs -type f -mtime +7

After that, delete all those files:

find /home/my-user/my-logs -type f -mtime +7 -delete

Here are the man page for the find command in arch manual page.