2

Suppose you want to find files modified in the last 5 minutes, using the find command.

The -mtime option, which can be used to specify a number of days, is documented as discarding any fractional part.

File was last modified n*24 hours ago. When find figures out how many 24-hour periods ago the file was last modified, any fractional part is ignored.

(Actually it's in the man page under -atime, where it has an analogous meaning. I've replaced "accessed" with "modified" here.)

In a script, it would be possible to do:

find $starting_dir -newermt "$(date -d '5 minutes ago' '+%Y-%m-%d %H:%M:%S')"

but this form is a bit unwieldy for convenient interactive use.

Is there a more concise formulation that can be conveniently remembered and typed when needed?

Assume that the GNU versions of common command-line tools are installed, but not any local customisations such as command aliases or helper scripts.

alani
  • 11,960
  • 2
  • 10
  • 22

1 Answers1

2

GNU find has -mmin primary for that. For example,

find -mmin -6

prints files that have been modified in the last five minutes.

oguz ismail
  • 39,105
  • 12
  • 41
  • 62