Ok, some hints:
To find older files you can use the find command with the -mtime option.
To keep 5 files of the selection you can pipe the result to awk, to ignore the first 5 files you can do something like:
Code:
awk 'NR<6{next}{print}'
So it should look like:
Code:
find <options> | awk '....' | rm -f
If you have many files you can use xargs.
Check the man page of find for the options, search on this forum or Google for examples.
Regards