I have to search for 3 types of files throughout a lot of directories (easily 1k + I think?) some of the files are 13 level deep.


Right now I am using the find command; I exclude whatever file path I can find so the find command doesn't go through the folders it has searched before. I have set the max depth to 13 (this is the deepest I can find). But still, the search is taking hours to complete. Any idea how can I improve the search time?

Ps: sorry I didn't post my script as I am currently at home and have no access to the pc in the company.


If your files are readable by others, you could use locate to find them quickly. A cronjob should update the locatedb daily (or more).

Here's an example :

$ time locate *.db
[a lot of .db files] 

real    0m0.036s
user    0m0.032s
sys     0m0.000s
  • Thanks, but locate cannot exclude certain directories. And also, there are lots of file that cannot be read by others.
    – Xeon
    Oct 23 '15 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.