find files between date x and date y

  • Follow


I need to search for all files accessed between Midnight and 12:30AM
within a set of directories and list the information in an ls -l
format.

How can I do something like that?  I know how to find file newer than X
or older than Y, but I can't get both these commands to work together
and produce some meaningful output.

Anyone have any ideas?

Thanks!
A.

0
Reply alistair.calder (5) 4/13/2006 2:31:43 AM

alistair wrote:
> I need to search for all files accessed between Midnight and 12:30AM
> within a set of directories and list the information in an ls -l
> format.
> 
> How can I do something like that?  I know how to find file newer than X
> or older than Y, but I can't get both these commands to work together
> and produce some meaningful output.
> 
> Anyone have any ideas?
> 
> Thanks!
> A.
> 
Touch 2 files, start_date and stop_date, like this:
$ touch -t 200603290000.00 start_date
$ touch -t 200603290030.00 stop_date

Ok, start_date is 03/29/06 midnight, stop_date is 03/29/06 30 minutes 
after midnight.  You might want to do a ls -al to check.

On to find, you can find -newer and then ! -newer, like this:
$ find /dir -newer start_date ! -newer stop_date -print

Combine that with ls -l, you get:
$ find /dir -newer start_date ! -newer stop_date -print0 | xargs -0 ls -l

(Or you can try -exec to execute ls -l.  I am not sure of the format, so 
you have to muck around a little bit)

HTH
-2
Reply Anonymous 4/13/2006 3:24:57 AM


Anonymous <anonymous@iscdemo.net> wrote:
> Combine that with ls -l, you get:
> $ find /dir -newer start_date ! -newer stop_date -print0 | xargs -0 ls -l

find -print0 and  xargs -0 are nonstandard (and won't work in Solaris).
If -print is not sufficient, you can use "-ls" (nonstandard, but works in
Solaris) or "-exec ls -l {} +" instead.

From the SUSv3:

A feature of SVR4's find utility was the -exec primary's + terminator. This
allowed filenames containing special characters (especially <newline>s) to
be grouped together without the problems that occur if such filenames are
piped to xargs. Other implementations have added other ways to get around
this problem, notably a -print0 primary that wrote filenames with a null
byte terminator. This was considered here, but not adopted. Using a null
terminator meant that any utility that was going to process find's -print0
output had to add a new option to parse the null terminators it would now
be reading.


-- 
Daniel
0
Reply Daniel 4/13/2006 4:04:19 AM

2 Replies
3077 Views

(page loaded in 0.079 seconds)

Similiar Articles:













7/20/2012 11:55:19 AM


Reply: