+5 votes
243 views
How to search for files according to the modification date in Linux

in Guides by (552k points)
reopened | 243 views

1 Answer

+3 votes
Best answer

How to search for files according to the modification date in Linux.
Complementary searches to the previous ones.

A few days ago a user of the forum asked us how to search files by user from the console , hence the idea of "‹"‹writing a small tutorial to search for files according to the date of modification in Linux . For this purpose we will use the find command, known for its great functionality and flexibility in Linux environments.

image

Searching according to the last date of modification of a file is simple, but we must know the appropriate syntax. It is a very useful type of search in different situations and that we should all know. I will show the different commands with their syntax.

How to search for files according to the modification date in Linux.

Search for files and folders that have been modified on the last day , that is, files modified within the last 24 hours:
find -mtime -1

The number -1 indicates a day, but we could use the number we wanted. For example, to search for modified files within the last week we would use 7 days with the command:
find -mtime -7

We can also specify minutes instead of days, but for this we would use the -mmin option. For example, to search for modified files in the last 30 minutes , we would use the command:
find -mmin -30

Complementary searches to the previous ones.

All the previous commands have their complements changing the symbol - by + . For example, in the first case, to search for files that have been modified more than a day ago we would use the command:
find -mtime +1

We can also search for modified files more than 7 days ago :
find -mtime +7

Or we can also specify a search for files that have been modified more than 30 minutes ago :
find -mmin +30

Sometimes it is useful to indicate the path where we want you to search , for example find /home/TechnoWikis -mmin +30 or restrict the search to a specific file extension find -mtime +3 -name "*.php" .

As always, it is advisable to have the find help page at hand, which we can access with the man find command and will show us all the options of this great search tool.


by (3.5m points)

Related questions

+4 votes
1 answer
+3 votes
1 answer
asked Aug 9, 2019 in Guides by backtothefuture (552k points) | 376 views
+5 votes
1 answer
+3 votes
1 answer
asked Aug 9, 2019 in Guides by backtothefuture (552k points) | 264 views
+5 votes
1 answer
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users