---
name: "locate"
section: "1"
platform: "openbsd"
package: "man"
version: "8.0-current-20261101"
release: "OpenBSD 8.0-current (2026-11-01)"
platforms: ["linux", "freebsd", "openbsd", "macos"]
url: "https://new.carta.tech/locate"
---

# locate(1)

find filenames quickly

## NAME

**locate** – find filenames quickly

## SYNOPSIS

**locate** \[**-bciS**\] \[**-d** *database*\] \[**-l** *limit*\] *pattern* *...*

## DESCRIPTION

The **locate** utility searches a database for all pathnames which match the specified *pattern*. By default, the database is recomputed weekly(8) and contains the pathnames 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\*”.

The database stores all bytes occurring in filenames except newline (‘\\n’) and NUL (‘\\0’). Internally, it uses a dedicated, compressed, undocumented format. For example, bytes less than 32 or greater than 127 are encoded as two bytes, whereas the 128 most frequent two-byte sequences are encoded as single bytes.

The options are as follows:

- **-b**

  For each entry in the database, perform the search on the last component of path.

- **-c**

  Suppress normal output; instead print a count of matching filenames.

- **-d** *database*

  Search in *database* instead of the default filename database. Multiple **-d** options are allowed. Each additional **-d** option adds the specified database to the list of databases to be searched.

  *database* may be a colon-separated list of databases. An empty database name is a reference to the default database.

  ```
  $ locate -d $HOME/lib/mydb: foo
  ```

  will first search for the string “foo” in *$HOME/lib/mydb* and then in */var/db/locate.database*.

  ```
  $ locate -d $HOME/lib/mydb::/cdrom/locate.database foo
  ```

  will first search for the string “foo” in *$HOME/lib/mydb* and then in */var/db/locate.database* and then in */cdrom/locate.database*.

  ```
  $ locate -d db1 -d db2 -d db3 pattern
  ```

  is the same as

  ```
  $ locate -d db1:db2:db3 pattern
  ```

  or

  ```
  $ locate -d db1:db2 -d db3 pattern
  ```

- **-i**

  Ignore case distinctions in both the pattern and the database. Since filenames are not character strings but merely opaque byte strings, **locate** ignores the [locale(1)](/locale/1.md) set by the user, always operates under the "C" locale, and the case rules employed are those of the ASCII character set.

- **-l** *limit*

  Limit output to a specific number of files and exit.

- **-S**

  Print some statistics about the database and exit.

## ENVIRONMENT

- LOCATE\_PATH

  Path to the locate database if set and not empty; ignored if the **-d** option was specified.

## FILES

- */etc/weekly*

  script that starts the database rebuild

- */usr/libexec/locate.updatedb*

  script to update the locate database

- */var/db/locate.database*

  locate database

## EXIT STATUS

The **locate** utility exits 0 on success, and \>0 if an error occurs. Zero matches are not considered an error.

## SEE ALSO

[find(1)](/find/1.md), [glob(7)](/glob/7.md), [locate.updatedb(8)](/locate.updatedb/8.md), weekly(8) Woods, James A., “Finding Files Fast”, *;login*, 8:1, pp. 8-10, 1983.

## HISTORY

The **locate** command appeared in 4.3BSD-Reno.

## BUGS

**locate** may fail to list some files that are present, or may list files that have been removed from the system. This is because **locate** only reports files that are present in a periodically reconstructed database (typically rebuilt once a week by the weekly(8) script). Use [find(1)](/find/1.md) to locate files that are of a more transitory nature.

The **locate** database is built by user “nobody” using [find(1)](/find/1.md). This will skip directories which are not readable by user “nobody”, group “nobody”, or the world. E.g., if your home directory is not world-readable, your files will *not* appear in the database.

The **locate** database is not byte order independent. It is not possible to share the databases between machines with different byte order. The current **locate** implementation understands databases in host byte order or network byte order. So a little-endian machine can't understand a locate database which was built on a big-endian machine.
