Operating System - HP-UX
1753622 Members
5963 Online
108797 Solutions
New Discussion

find files between certain time ranges

 
SOLVED
Go to solution
allanm77
Frequent Advisor

find files between certain time ranges

Hi!

 

I need a way to find files between certain times within the same day.

 

Lets say I want to find out -  between 4pm and 5pm which files got modified?

 

Thanks,

Allan.

3 REPLIES 3
Pete Randall
Outstanding Contributor
Solution

Re: find files between certain time ranges

Use the find command in combination with the touch command.  First touch two files with your starting and ending times (man touch).  Then run find using those reference files for comparison.

 

find /dir -newer startfile ! -newer endfile (man find for details)


Pete
James R. Ferguson
Acclaimed Contributor

Re: find files between certain time ranges

Hi:

 

This has been asked hundreds of times, but here's one way:  Touch two reference files, for example:

 

# touch -amt 07121600.00 /tmp/ref1

# touch -amt 07121700.00 /tmp/ref2

# find . -xdev -type f -newer /tmp/ref1 -a ! -newer /tmp/ref2 -print

 

Of course, if you are using the GNU 'find' you have more granular arguments like '-mmin'.  Then too, Perl can do this without the need for temporary files, too!

 

Regards!

...JRF...

 

James R. Ferguson
Acclaimed Contributor

Re: find files between certain time ranges

Hi (again) Allan:

 

By the way, please evaluate your other posts:

 

http://h30499.www3.hp.com/t5/Languages-and-Scripting/Perl-or-shell-script/td-p/4819163

 

...JRF...