1752681 Members
5704 Online
108789 Solutions
New Discussion юеВ

the use of find

 
hy_3
Frequent Advisor

the use of find

I want to delete some files under a directory that were created during 2004-jun-20 20:00:00 and 2004-jun-20 22:00:00.How should I do?Thank you.
6 REPLIES 6
Dmitry Timoshenko
Frequent Advisor

Re: the use of find

Hello,

There is no way to specify time of file creation. Only date.

The possible usage is:
find . -name "*something*" -ctime -1 -ls

This will give you a list of files, created today and yesterday.
If you need this operation to run periodically, you should use pipeline to sort output.

Best regards,
Dmitry.
hy_3
Frequent Advisor

Re: the use of find

Thank you.Could you tell me the detail that how to delete the output of find?
Dmitry Timoshenko
Frequent Advisor

Re: the use of find

Hi,

If you`re sure that you`ll delete what you exactly want. You can execute find this way:
#find .... -exec \ rm {} \;

But I would like to recommend you to check the list first and than kill your files manually.

Dmitry.
Michael Schulte zur Sur
Honored Contributor

Re: the use of find

Hi,

what Dmitry says is not correct. While find itself has no means to find files on an hour base, it has options to compare with a reference file with -newer.
This reference file can be created/updated by touch.
So create/update with touch two reference files, once with date 2004-jun-20 20:00:00 and the other with 22:00:00
Then use -newer and ! -newer to find your files.

greetings,

Michael
Dmitry Timoshenko
Frequent Advisor

Re: the use of find

Sorry, Michael, but I didn`t say, that this will work on hour base.
I also think, that your proposal is better, but i didn`t use this way on practise.

Dmitry.
Michael Schulte zur Sur
Honored Contributor

Re: the use of find

Hi Dmitry,

no offense meant!

;-)

Michael