Home » Infrastructure » Unix » Finding older files using find command
Finding older files using find command [message #549033] Tue, 27 March 2012 11:16 Go to next message
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 #549040 is a reply to message #549033] Tue, 27 March 2012 12:00 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Please, note that this is an Oracle forum; "Unix" means that we discuss Oracle-related problems on Unix platforms. You question, on the other hand, doesn't seem to be related to Oracle, so - perhaps you'd rather search for an answer elsewhere (i.e. on one of strictly Unix forums).
Re: Finding older files using find command [message #552429 is a reply to message #549040] Wed, 25 April 2012 14:00 Go to previous message
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>

Previous Topic: Kernel patch upgrade in sun solaris
Next Topic: oracle 10g installation problem in RHEL 6
Goto Forum:
  


Current Time: Thu Mar 28 10:34:59 CDT 2024