This tutorial will help you to find files created or modified before X days. Here X means any number (eg: 1,2 or 30). Using find command you can also search which is created or modified before X minutes.
1. Search files created/modified before 30 days
Use this command to search all files created or modified before 30 days in /var/backup directory. Find provides the option -mtime
to define number of days.
Advertisement
find /var/backup -type f -mtime -30
You can also search file created before 30 minutes using -mmin
optiopn.
find /var/backup -type f -mmin -30
2. Search files with specific extension
You can also search file for a specific extension. For example to search all files with extension “.log” under /var/log directory.
find /var/log -name "*.log" -type f -mtime -30
Or search speficif extension file created before 30 minutes.
find /var/log -name "*.log" -type f -mmin -30
The above command will show only files having a .log extension.