Finding older files using find command [message #549033] |
Tue, 27 March 2012 11:16 |
Nshan
Messages: 62 Registered: February 2009
|
Member |
|
|
Hi All,
I want to find files which are older than 15 days.
I have written a command as below,
find -mtime +15 -print
I understand (System date - last modified time of a file) should be greater than or equal to 15 days.
This command returns files which are 15 days old..
i.e 16,17,18,19 etc...
But if time difference is a fractional value which is less than next integer 16 (ex - 15.67) actually greater than 15, then those files are not getting listed.
Is there any other way through which i can meet such type of requirement.
Appreciate your inputs.
Thanks,
Nshan
|
|
|
|
Re: Finding older files using find command [message #552429 is a reply to message #549040] |
Wed, 25 April 2012 14:00 |
andrew again
Messages: 2577 Registered: March 2000
|
Senior Member |
|
|
Very good ref site ==> http://www.softpanorama.org/Tools/Find/selecting_files_by_age.shtml
-mmin, -daystart might apply to your O/S too.
#Solaris test case:
# create reference file with specific datetime
user1> touch -t 201201091054 ref_time.txt
user1> ls -ltr sqlplus_tst.ksh ref_time.txt
-rwx------ 1 user1 users 599 Jan 9 10:53 sqlplus_tst.ksh
-rw-r--r-- 1 user1 users 0 Jan 9 10:54 ref_time.txt
# find files not newer than ref file
user1> find . -name "*.ksh" ! -newer ref_time.txt -exec ls -l {} \;
-rwx------ 1 user1 users 599 Jan 9 10:53 ./sqlplus_tst.ksh
# ref file is newer
user1> touch -t 201201091052 ref_time.txt
user1> ls -ltr sqlplus_tst.ksh ref_time.txt
-rw-r--r-- 1 user1 users 0 Jan 9 10:52 ref_time.txt
-rwx------ 1 user1 users 599 Jan 9 10:53 sqlplus_tst.ksh
# now the script doesnt meet the criteria
user1> find . -name "*.ksh" ! -newer ref_time.txt -exec ls -l {} \;
user1>
|
|
|