How to Search Files Created within X Days/Hours in Linux

Channel: Linux
Abstract: .logOr search specific extension file created within 60 minutes (1 hour). find /var/log -name "*.log" -type f -mmin +60

This tutorial will help you to find files created or modified within X days. Here X means any number. Using the find command you can also search which is created or modified within X minutes.

1. Search files created/modified within 30 days

Use this command to search all files created or modified within 30 days in /var/backup directory. Find provides the option -mtime to define number of days.

find /var/backup -type f -mtime +30

You can also search file created within 60 minutes (1 hour) using -mmin optiopn.

find /var/backup -type f -mmin +60
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 specific extension file created within 60 minutes (1 hour).

find /var/log -name "*.log" -type f -mmin +60

The above command will show only files having a .log extension.

Ref From: tecadmin

Related articles