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.

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

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>