I can locate my home!
locate
and updatedb
make a beautiful pair. updatedb
builds,
usually once a day, a database of filenames on your computer, and
locate
searches that database.
So, instead of doing a system-wide find
when you're looking for a
file somewhere (as in anywhere), you can use locate
to search
through the database, which is way faster.
Unfortunately, NFS shares are excluded from the database here at work, so a lot of neat stuff - pretty much all the neat stuff, really - just isn't locate-able.
Which is why I build my own database.
updatedb
runs every night at 4:15, courtesy of my crontab:
# min(0-59) hour(0-23) dom(1-31) mon(1-12) dow(0-6:sunfirst) command
15 4 * * * updatedb --database-root /home/ME --output /home/ME/.locate.db
That creates .locate.db
, containing all the file names in my home
directory.
In addition to that, I set two aliases in my .bashrc
:
alias locate="locate --database /home/stp02/salo/.locate.db:"
alias hlocate="locate --database /home/stp02/salo/.locate.db"
That makes locate
search my database as well as the default one (the
--database
option takes a colon-separated list of databases, and an
empty entry is taken to mean the default db), and hlocate
searches
only my home directory.
Sweet and neat. I could build additional databases for other
interesting NFS shares, and add these to the locate
alias, too. But
I'm hungry.