Operating System - HP-UX
1846764 Members
4157 Online
110256 Solutions
New Discussion

Re: 'find' command - help req'd !

 
SOLVED
Go to solution
Simon R Wootton
Regular Advisor

'find' command - help req'd !

I have a directory containing 80 sub-directories, each sub-dir contains hundreds of files.

From these directories, I want to find a list of files created between 17:20 and 17:30 on 23 June 2003, or if that's not possible, a list of files created on 23 June 2003 without the time criteria.

All help rewarded today !

Thanks in advance
Simon
7 REPLIES 7
Pete Randall
Outstanding Contributor
Solution

Re: 'find' command - help req'd !

Simon,

How about something like this:

find /directory_name -exec ll {} \; |grep 'Jun 23' |grep '17:2[0123456789]'


Pete

Pete
Andreas Voss
Honored Contributor

Re: 'find' command - help req'd !

Hi,

create two file for search criteria:

touch 06231720 /tmp/a
touch 06231730 /tmp/b

then do the find:

find -newer /tmp/a ! -newer /tmp/b

Regards
Jean-Louis Phelix
Honored Contributor

Re: 'find' command - help req'd !

Hi,

You should first create 2 dummy files with timestamps :

$ touch -t 06231720 ffirst
$ touch -t 06231730 flast

Then use :

find . -newer ffirst ! -newer flast

Regards
It works for me (© Bill McNAMARA ...)
James R. Ferguson
Acclaimed Contributor

Re: 'find' command - help req'd !

hi Simon:

Create with 'touch' two "reference" files:

# touch -amt 06231719 /tmp/ref1
# touch -amt 06231730 /tmp/ref2

# cd dir
# find . -newer /tmp/ref1 -a ! -newer /tmp/ref2

Regards!

...JRF...
Simon R Wootton
Regular Advisor

Re: 'find' command - help req'd !

Thankyou people - problem solved !!!!

Simon
Elena Leontieva
Esteemed Contributor

Re: 'find' command - help req'd !

Simon,

Try this:
touch -t 0623172003 /tmp/t1
touch -t 0623173003 /tmp/t2
find . -newer /tmp/t1 ! -newer /tmp/t2 -print
rm /tmp/t[12]

This is from UNIX Power Tools.

Elena.
Michael Kelly_5
Valued Contributor

Re: 'find' command - help req'd !

Simon,
a word of warning, unix does not store the creation date/time for files. It stores the modification and last access times for the file and the modification time for the inode.
If any of the files you are interested in were modified after 17:30 then Andreas' method will not list them.
If you are confident that the inode details have not changed since the files were created then you can use Andreas' method but change -newer to -newercm

HTH,
Michael.
The nice thing about computers is that they do exactly what you tell them. The problem with computers is that they do EXACTLY what you tell them.