0

It's relatively simple to use find to look for recent files.

find . -cmin -5 will look for all files changed in the last 5 minutes under the current directory.

But find is very much slower than mdfind, which is powered by Spotlight's index when you search the whole machine.

What is the simplest way, on the terminal, to ask mdfind to only look for files modified in the last 5 minutes? Every time I look at the Apple doc I get totally lost as to what you actually type on the command line.

  • There is kMDItemFSContentChangeDate but this is absolute date/time so you would need to do some date arithmetic first. – nohillside Feb 7 at 8:13
  • I’d accept an actual answer if it the example in it worked. – JL Peyret Feb 7 at 18:16
2

You would use the time variable- $time.now and subtract the number of seconds- $time.now(-300) to get 5 minutes before the current time. Next, you would use the operator >= for the comparison. To put it all together-

 mdfind -onlyin . 'kMDItemFSContentChangeDate >= $time.now(-300)' 
  • That works. Seems a bit tricky to wrap in a bash function but it certainly got me started. I do wish this feature had better docs. – JL Peyret Feb 12 at 20:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .