Delete all but the most recent X files in bash is quite simple and is particularly useful for logs and backups scripts.
Delete old log files except the latest 10
rm `ls -t *.log|awk 'NR >10'`
Delete all the zip files except the newest 2.
rm `ls -t *.zip|awk 'NR >2'`