Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find file accessed/created just few minutes ago

I always forget which file I edit one minutes ago, so I input find . -cmin 1 or some other value but it worked exactly 1 minutes. I had to try find . -ctime 2 /*or 3,4...*/.

Then I find another approach which be better:

touch -t 12251134 empty /*similar format which 5 or 10 minutes ago */ find . -newer empty 

I can use date -d'-5minutes' +%m%d%H%M caculate the time for me. I want to know if there is a simple way to find files accessed 1, 2 or 3... minutes ago.

like image 519
yuan Avatar asked Dec 25 '12 16:12

yuan


People also ask

How do you find all files which are modified 10 minutes before?

Syntax of find command with “-mmin n” option -n : find command will look for files modified in last n minutes. +n : find command will look for files modified in before the last n minutes i.e. which are not modified in last n mins. n : find command will look for files which are modified exactly n minutes ago.

How do I see files created by date?

In the File Explorer ribbon, switch to the Search tab and click the Date Modified button. You'll see a list of predefined options like Today, Last Week, Last Month, and so on. Pick any of them. The text search box changes to reflect your choice and Windows performs the search.

Which command will to find all files which are changed in last 1 hour?

Thus find -ctime 0 finds everything for which the inode has changed (e.g. includes file creation, but also counts link count and permissions and filesize change) less than an hour ago.


1 Answers

Simply specify whether you want the time to be greater, smaller, or equal to the time you want, using, respectively:

find . -cmin +<time> find . -cmin -<time> find . -cmin  <time> 

In your case, for example, the files with last edition in a maximum of 5 minutes, are given by:

find . -cmin -5 
like image 163
Rubens Avatar answered Sep 20 '22 09:09

Rubens