Find files older than X days and save ouput into a file

The below Linux command will help you to find files older than 35 days in a specific directory path and save the ouput in backupfiles.log

Here the directory we are searching is /backup/logs and -mtime specifies the modified time of a file. We are saving the list of all the files which are older than 35 days in backupfiles.log

find /backup/logs -type f -mtime +35 -print > backupfiles.log &

Find files older than 7 days and print output on screen

If you want to print files older than 7 days on screen and do not want to save it into a file, use below command

find /backup/logs -type f -mtime +7 -print

Find files in current directory older than 28 days and remove them

Below linux command will find all the files under current location (as we have specified . dot), search file name starting with arch and ending with log. check file create time with -ctime older than 28 days and then remove those files using rm -f

find . -name arch\*log -ctime +28 -exec rm -f {} \;