Operating System - HP-UX
1830080 Members
15238 Online
109998 Solutions
New Discussion

Find files recursively by date range ?

 
SOLVED
Go to solution
Mark A. Smith
Occasional Advisor

Find files recursively by date range ?

What is the command to search my directory and subdirectors recursively to find files by date range, in this case 01/01/00 thru 12/31/05 ?
3 REPLIES 3
Coolmar
Esteemed Contributor

Re: Find files recursively by date range ?

I found this....try it out, it may work for you:

olddate="200407010001"
newdat="200407312359"
touch -t $olddate ./tmpoldfile
touch -t $newdat ./tmpnewfile
find /path/to/directory -type f -newer a ./tmpoldfile ! -newer a ./tmpnewfile
James R. Ferguson
Acclaimed Contributor
Solution

Re: Find files recursively by date range ?

Hi Mark:

Since the Forum has been out-to-lunch the past hour or so, it's taken until now to post this.

# touch -amt 200001010000 /tmp/ref1
# touch -amt 200512312359 /tmp/ref2

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

The 'touch' creates two boundries for a search based on a file's 'mtime' (modification timestamp).

The 'find' searches the '/path' you choose; does not cross mountpoints ('-xdev'); and returns *files* but not directories, pipes, sockets, etc.

Regards!

...JRF...
Mark A. Smith
Occasional Advisor

Re: Find files recursively by date range ?

the last response from J. Ferguson was more clear and answered my question, closing thread now.