Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding 5000 oldest files from a directory 1

Status
Not open for further replies.

balajipn

Programmer
Mar 30, 2004
65
IN
Hi,
I have a directory /logo/jpg/CustArtRepository which contains around a million files in it. My requirement is to search the oldest 5000 files from this directory and its subdirectories and move them to a archive directory. I am using the following command.

find /logo/jpg/CustArtRepository -type f -name "*" -exec ls -ltr {} \; 2>/dev/null

However, the above command take a very long time since there are nearly 10000 subdirectories under this. I would like this search to end as soon as it finishes its first 5000 files.

Is this possible? Can some one help me?


Thanks,
Balaji.

 
Hi

Here on Tek-Tips we used to thank for the received help by giving stars. Please click the

* [navy]Thank Annihilannic
for this valuable post![/navy]


at the bottom of Annihilannic's post. That way you both show your gratitude and indicate this thread as helpful.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top