I often use locate as a command to find stuff system-wide. However, I find it very annoying that the osx version of locate doesn't seem to have the -b option to match the basename only; and so prints all the content of every folder that matches the query. It also doesn't have the -e option for checking whether the files have been removed since the last update of the database.

On my linux machine (Ubuntu 20.04), those options, and many others, exist. The man page for it shows the date Sep 2012, while the Mac shows August 2006.

Are these two entirely different programmes or different versions of the same? How do I get the better locate on Mac?


Mac BSD and GNU Linux are shipping different "locate" program. Locate has advantages over find, for pros and cons I will refer you to: This page. However, there are some other options on mac like:

mdfind -name file.pdf

For archlinux, I am using plocate (compatible with mlocate).

How do I get the better locate on Mac?

Locate is only report files that are present in the database (if I am not mistaken it gets updated once a week), you can also use find with specified directory. Indexing is the key.

Good luck

  • Thank you, I knew about find but was asking about locate specifically. Nevertheless your answer pointed me in the right direction.
    – Martino
    Feb 11 at 9:13

Kasa's answer pointed me to the right direction: these are two different programmes. The Linux locate is actually mlocate, and can be installed on Mac with some struggles, as some people have done, while the Mac locate is a different and older version. More about the difference in this answer.

However, the easier way is to use mdfind, which is already installed on Mac (it's probably the thing behind Spotlight) and follows the same principles and seems to be better than the old BSD locate. This allows for non-case-sensitive queries and for basename-only queries as I requested.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.