Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
11
rated 0 times [  11] [ 0]  / answers: 1 / hits: 2299  / 3 Years ago, fri, june 11, 2021, 8:48:42

I was looking for a file in my source and tried both locate and find.
Surprisingly locate was searching in entire machine and was faster than find, which was searching only in current directory and sub directories.



Here are my shell commands for both:



find . -name vendorsetup.sh # takes 50 seconds to search all files in curren -sub directories.

locate vendorsetup.sh # takes 20 seconds to search file in whole machine.


Why this?


More From » find

 Answers
2

locate uses a database and periodically does an inventory of your file system. The database is optimized for searching. find needs to traverse the whole subdirectory, which is pretty fast, but not as fast as locate.


[#24029] Saturday, June 12, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
izecaptur

Total Points: 113
Total Questions: 102
Total Answers: 114

Location: Northern Mariana Islands
Member since Fri, Jan 15, 2021
3 Years ago
;