Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
22
rated 0 times [  22] [ 0]  / answers: 1 / hits: 19390  / 1 Year ago, tue, february 28, 2023, 7:28:07

I'd like to use mlocate on my Ubuntu server, but only to index certain directories (e.g. /home and /data, but not everything under /). However, mlocate's standard configuration works the opposite way; you specify the paths you want to remove (with PRUNE_PATHS).



Is there any easy way to achieve this, or any similar utility that will do what I want? (note: it should maintain an index like mlocate, so find is not acceptable, for example) Thanks.


More From » search

 Answers
7

You can use the -U option (--database-root PATH)



updatedb -l 0 -U /home/user/music -o /home/user/databasefile


-o writes to the output file



-l 0 makes that you can read it, otherwise it is only accessible for locate



Then you can then use it like:



locate -d /home/user/databasefile Dylan


-d sets the databasepath



To use mlocate with more than one root directory, simply create two databasefiles, and use locate with two databasepath's options like this:



locate -d /home/user/dbfile1 -d /home/user/dbfile2 searchstring


To sum it up and answer the question more specific:



updatedb -l 0 -U /home -o /home/user/home_dbfile
updatedb -l 0 -U /data -o /home/user/data_dbfile
locate -d /home/user/home_dbfile -d /home/user/data_dbfile Dylan

[#37040] Wednesday, March 1, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ampolinhad

Total Points: 88
Total Questions: 100
Total Answers: 116

Location: South Georgia
Member since Tue, Feb 1, 2022
2 Years ago
ampolinhad questions
Thu, Sep 8, 22, 15:45, 2 Years ago
Tue, Aug 10, 21, 20:03, 3 Years ago
Sat, Oct 16, 21, 22:44, 3 Years ago
Sat, Oct 23, 21, 03:11, 3 Years ago
Thu, Nov 17, 22, 15:34, 1 Year ago
;