Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Linux Ask!

Jan 072009
 

Becareful when using the mtime option in find command

Answer:

A simple command like the following is very handy when finding all the files in the current directory which have been modified within 1 day.

# find -type f -mtime -1

But the above interpretation is simply wrong!

The real meaning of the above command is: Find all the files in the current directory which have been modified less than 2 days.

So if a file is modified before 1.9999999.. day, it still match the above command since the fractional part is ignored.

Try it yourself if you don't believe.

Reference:

man find