How To Find Files Modified in Last 30 Days in Linux?

In Linux, we can use the find command in order to search the files across the file system. There might be a case when you require to search the files that are modified before the x days. To find such files you need to use -mtime option together with the find command to find out the files that are modified before x days.

You can use the Number of days in two different formats.

+  with number of days to search the file modified older than X days

–  with number of days to search the file modified within last X days

Command to find the files that are modified in the last X days

Run the below command to find out the files and directories that are modified in the last 25 days. If you add dot (.) in this command to search files in the current directory. Here, -mtime -25 means the files that are modified in the last 25 days. You can change the number as per your requirement. 

find . -mtime -25

You can also customize the search based on the file type. Use -type followed with -f (file) or -d (directory). Below command will search for files only.

If you want to customize your search and just want to find the files only then you can use the below command.

find . -type f -mtime -25

Command to Find the files that are modified before X days

You can run the below command to search the files and directories that are modified before 25 days. Add dot (.) in this command to search files in the current directory. Here, -mtime +25 means files that are modified before 25 days. You can change the number as per your requirement. 

find . -mtime +25

If you want to customize your search and just want to find the files only then you can use the below command.

find . -type f -mtime +25

Related Articles

How to remove Swap Space from Centos 7.x?

Please refer to the following steps to remove Swap space from Centos 7.x At first, check if...

Do You Provide TUN/TAP On VPS Hosting?

Typically, TUN/TAP is used when you want to utilize VPN services from your VPS. Windows VPS...

How to install Dotnet Core on Centos 7 ?

Dotnet Core is now available with the Linux OS. Following are the steps to install Dotnet Core on...

How to verify Linux System Is 32-bit or 64-bit?

You will find 64-bit OS in most modern computers. It is always recommended to have a 64-bit OS...

Is it possible to take complete VPS backup in VPS itself?

Please note that, there is no provision to take backup of full VPS image in VPS itself. As an...

  • 0 Users Found This Useful

Was this answer helpful?