Home OS X
OS X Syntax

locate

Find files.

SYNTAX

      locate pattern

locate searches a database for all pathnames which match the specified pattern. The database is recomputed periodically, and contains the path- names of all files which are publicly accessible.

Shell globbing and quoting characters (`*', `?', ``\'', `[' and `]') may be used in pattern, although they will have to be escaped from the shell.

Preceding any character with a backslash (`\') eliminates any special meaning which it may have. The matching differs in that no characters must be matched explicitly, including slashes (`/').

As a special case, a pattern containing no globbing characters (`foo') is matched as though it were `*foo*'..

Files
   /var/db/locate.database       Database
   /usr/libexec/locate.updatedb  Script to update database.

EXAMPLES

Switch to root and build/update the database.

   sudo /usr/libexec/locate.updatedb

Search the database for files with names containing "foo",
or in folders with names containing "foo"

   locate foo

Search the database for files with names ending in ".jpg"
(but not in folders ending in ".jpg")   

   locate '*.jpg'

Related commands:

find - Search for files that meet a desired criteria
grep - Search file(s) for lines that match a given pattern
ln - Make links between files (hard links, symbolic links)
ls - List information about file(s)
where - Report all known instances of a command
which - Locate a program file in the user's path

Equivalent BASH command:

locate
- Find Files



Back to the Top

Simon Sheppard
SS64.com