Operating System - HP-UX
1832501 Members
4783 Online
110043 Solutions
New Discussion

Re: listing file of date range

 
SOLVED
Go to solution
Henry Chua
Super Advisor

listing file of date range

Hi Guys,

Is there any way I can list files that have been created between a certain date say from 21-05-2005 to 27-05-2005 in a directory..


Best regards
Henry

6 REPLIES 6
Pete Randall
Outstanding Contributor
Solution

Re: listing file of date range

You can use find with the -newer option - something like this:

touch -t 050521 reffile.oldest
touch -t 050527 reffile.newest

find /target_dir \(-newer refile.oldest -o ! -newer reffile.newest)

I believe that should do it.


Pete

Pete
Vibhor Kumar Agarwal
Esteemed Contributor

Re: listing file of date range

Just create 2 files with those timestamps.
Then

find . -type f \( -newer start_date_file \) -a \( !-newer end_date_file \)

Not sure of the syntax.
Vibhor Kumar Agarwal
Vibhor Kumar Agarwal
Esteemed Contributor

Re: listing file of date range

Ooops,
Somebody replied while I was writing.

Pete, will there be "or" or "and".
Vibhor Kumar Agarwal
Pete Randall
Outstanding Contributor

Re: listing file of date range

Not sure - I would try it with "or" and see what I get, then try "and", if necessary.


Pete

Pete
Henry Chua
Super Advisor

Re: listing file of date range

Hi guys,

Thanks for the tip.. i tried it with an and - works fine..

find . -type f -newer from -a ! -newer to > LIST

... I output the data to a path.. but discovered there aren't sort by date.. is there any other option in "find" i can use to achieve this?

Regards
Henry
Pete Randall
Outstanding Contributor

Re: listing file of date range

You could pipe it through sort . . .


Pete

Pete