Tag Archive for 'mlocate'

Find Files Of A Given Name Instantly

Usually when I have to find a file, I use a find and a grep command together – because I still haven’t learnt to use find properly. This is what I do:

find -L . | grep <name>

But this process is usually slow as it traverses the whole directory structure recursively following the symlinks to find all the files and then greps for the name that I need.

Recently I learnt about a faster way of doing the same – use locate to find files of a given name quickly. The command is:

locate <name>

It creates an index of all the files on the system and searches off it when called for. The index is rebuilt (by default) once a day by a cron’d find so results maybe stale by 24 hours.

If locate is not already present on your system, you could install it by:

sudo yum install mlocate

From the SDE Tip – Amazon

Popularity: 1% [?]