How to find access to a file / created just a few minutes ago

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

Then I find another approach that is 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 to determine the time for me. I want to know if there is an easy way to find the files available 1, 2 or 3 ... minutes ago.

+52
linux unix bash shell find
Dec 25
source share
4 answers

Just indicate whether you want the time to be longer, less than or equal to the time you want using:

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

In your case, for example, files with the latest version of no more than 5 minutes are given by:

 find . -cmin -5 
+79
Dec 25 '12 at 16:21
source share

If you have GNU find, you can also say

 find . -newermt '1 minute ago' 

The t parameters make the reference "file" for newer reference to the sort reference date that you could pass to GNU date -d , which understands the complex date specifications, as described above.

+10
Dec 26
source share

To find files available 1, 2 or 3 minutes ago, use -3

 find . -cmin -3 
+7
Dec 25 '12 at 16:21
source share

If you know that the file is in your current directory, I would use:

 ls -lt | head 

Listed here are your most recently modified files and directories. In fact, I use it so that I have the alias "lh".

+3
Dec 26
source share



All Articles