Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Linux Script - Find Command

frank.anelliaMar 24 2016 — edited Apr 7 2016

Hello,

I am attempting to find files older than 1 day in a directory.  The directory contains the following:

/u01/app/oracle/test> ls -l

total 12

drwxrwxr-x 2 oracle oinstall 4096 Mar 24 10:39 archive

-rw-r--r-- 1 oracle oinstall  429 Mar 23 10:19 rotate_backups.log

drwxr-xr-x 2 oracle oinstall 4096 Feb 24  2014 scripts

-rw-r--r-- 1 oracle oinstall    0 Mar 22 10:37 test1.log

-rw-r--r-- 1 oracle oinstall    0 Mar 22 10:37 touch2.log

-rw-r--r-- 1 oracle oinstall    0 Mar 22 10:37 touch3.log

When I run the following 'find . -maxdepth 1 -type f -mtime +1' it returns only 3 files.  The command should return anything older than a day?

/u01/app/oracle/test> find . -maxdepth 1 -type f -mtime +1

./touch2.log

./test1.log

./touch3.log

Now if I run 'find . -maxdepth 1 -type f -mtime -2' it returns the file that is less than 2 days old. 

/u01/app/oracle/test> find . -maxdepth 1 -type f -mtime -2

./rotate_backups.log

How do I return any files older than 1 day?  I would think '-mtime +1' was the answer.  Is there a date/time value I should set on the host to get the proper results.  All the files in the directory are older than a day.

Thanks,

Frank

This post has been answered by Dude! on Mar 24 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 5 2016
Added on Mar 24 2016
3 comments
1,245 views