Skip to content

Instantly share code, notes, and snippets.

@ianchen06
Last active September 16, 2015 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianchen06/5ce773aabba1b743b664 to your computer and use it in GitHub Desktop.
Save ianchen06/5ce773aabba1b743b664 to your computer and use it in GitHub Desktop.
Custom mlocate(locate) database for locate searching

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 MyFileName

-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 MyAwesomeFileName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment