locate

output files in databases that match a pattern

GNU version of locate.

⌘ MAC OS X

locate [-d path | --database=path]
[-e | -E | --[non-]existing]
[-i | --ignore-case]
[-0 | --null]
[-c | --count]
[-l N | --limit=N]
[--version]
[--help]
[-w | --wholename] | [-b | --basename]
[-S | --statistics]
[-r | --regex ]
[-P | | -H | --nofollow]
[-L | --follow]
[-A | --all]
[-p | --print]
pattern
Searches databases of file names created by updatedb and outputs names that contain pattern.

The databases entries includes all parent directories and / and . are not treated specially in pattern.

If pattern is a plain string (i.e. it contains no metacharacters), all names that contain that string are output as if pattern began and ended with *.
For example: hive is equivelent to *hive* and
foo*bar will match names containing fooMybar as well as foo3/bar and *duck* can match a name that contains lake/.ducky.

Patterns can contain shell-style metacharacters: *, ?, and [] (which may need to be quoted to protect them from shell expansion).
patterns including metacharacters may need to begin with * (to match parent directories).

Output going to a terminal will have control characters escaped in the same way as the -print action of find

-S
--statistics
Output statistics about the database and exit (unless --print or--count is present)
Database /var/cache/locate/locatedb is in the GNU LOCATE02 format.
Locate database size: 929379 bytes
All Filenames: 81656
File names have a cumulative length of 3741662 bytes.
Of those file names,

    132 contain whitespace, 
    0 contain newline characters, 
    and 11 contain characters with the high bit set.
Compression ratio 75.16% (higher is better)


⌘ Database: /var/db/locate.database Compression: Front: 12.16%, Bigram: 58.37%, Total: 8.59% Filenames: 1118792, Characters: 132012888, Database size: 11336742 Bigram characters: 4719461, Integers: 71763, 8-Bit characters: 2344
-w
--wholename
Compare whole name (including parent directories). default.
-b
--basename
only the final component of the name is compared.
-l N
--limit=N
Limit the number of matches .
-c
--count
Output a count of matches(not to exceed -l)
-p
--print
Output results with --statistics or --count
-A
--all
Output only names which match all non-option arguments, not those matching one or more non-option arguments.
-i
--ignore-case
 
-e
--existing
Only output names that currently exist (instead those that existed when the database was created).
This will take significantly longer ( It is possible for a file to be deleted after being checked, but before you access it)
-E
--non-existing
Output names that currently do not exist (i.e. deleted since the database was built)
-L
--follow
Symbolic links are considered non-existing. Default.
-P
-H
--nofollow
Symbolic links that are BROKEN are treated as existing files.
-0
--null
Use ASCII NUL as a separator, instead of newline.
-r
--regex
pattern is a regular expression as in find except . matchs a newline.
Names whose full paths match the specified regular expression are considered matching.
To anchor regular expression at the ends of the full path name, use ^ and $ .

-d path
--database=path
databases are located in path, a colon-separated list of database file names overriding $LOCATE_PATH .
Empty elements in the path indicate the default database.
A database can be supplied on stdin using - as an element of path. If more than one element of path is -, later instances are ignored and a warning message is printed.
--help  
--version 

Environment

LOCATE_PATH   Colon-separated list of databases to search.
With a leading or trailing colon, or has two colons in a row, results vary between different versions of locate.

See

find, locatedb(5), updatedb, xargs, glob.

BUGS The locate database handles filenames containing newlines if the system's sort suppports -z . If you suspect that locate may need to return filenames containing newlines, consider using --null.

Use Savannah.gnu.org to submit bugs.
Join the bug-findutils mailing list, send email to tbug-findutils-request@gnu.org


updatedb - update a file name database for locateGNU version

updatedb [options]

The file name databases contain lists of files that were in the directory when the databases were last updated.
The name of the databases is determined when locate and updatedb are configured . The frequency with which the databases are updated and the directories for which they contain entries depend on how often updatedb is run, and with which arguments.

In networked environments, it often makes sense to build a database at the root of each filesystem, containing the entries for that filesystem. updatedb is run for each filesystem on the fileserver where that filesystem is on a local disk, to prevent thrashing the network. Users can select which databases locate searches using an environment variable or command line option; see locate. Databases can not be concatenated together.

--findoptions=option1 -option2... Global options to pass to find.
The environment variable FIND‑OPTIONS sets this value. Default is none.

--localpaths=/path1 path2... Non-network directories to put in the database. Default is /.

--netpaths=path1 path2... Network (NFS, AFS, RFS, etc.) directories to put in the database.
The environment variable NETPATHS sets this value. Default is none.

--prunepaths=path1 path2... Directories to exclude. ( no trailing slashes )
The environment variable PRUNEPATHS sets this value. Default /tmp /usr/tmp /var/tmp /afs.

--prunefs=path… File systems to exclude.
The environment variable PRUNEFS sets this value. Default is nfs NFS proc.

--output=dbfile file to build, default is /var/cache/locate/locatedb.

--localuser=user The user to search non-network directories as, using su. Default is to search the non-network directories as the current user.
The environment variable LOCALUSER .

--netuser=user The user to search network directories as, using su. Default is daemon.
the environment variable NETUSER .

--old-format Create the database in the old format

--version display the version number of updatedb and exit.
--help display a summary of the options to updatedb and exit.


Secure locate

updatedb [-qv][--output=file]

-l level secutiry level. 0 disable, faster. detault 1
-e dir,dir exculde paths
-u starting path at / default.
-U dir stating path at dir
-o filedb
--output=filedb
output database. default /var/lib/slocate/slocatedb
-c confile default /etc/updatebd.conf
 # Filesystems that are pruned from updatedb database
PRUNEFS="auto mqueue proc supermount devpts afs autofs cifs devfs   
            eventpollfs futexfs gfs  
            hugetlbfs iso9660 ncpfs nfs NFS nfs4 nfsd nnpfs 
            pipefs ramfs rpc_pipefs selinuxfs sfs shfs smbfs 
            sockfs spufs subfs sysfs tmpfs udf usbfs vperfctrfs"

# Paths which are pruned from updatedb database
PRUNEPATHS="/tmp /var/tmp /root/.ccache"

# nice value to run at: see -n in nice(1)
NICE="10"

# ionice class to run at: see -c in ionice(1)
IONICE_CLASS="2"

# ionice priority to run at: see -n in ionice(1)
IONICE_PRIORITY="7"
-q quiet no error messages
-v verbose

BUGS

Correctly handles filenames containing newlines (who makes files with newlines anyway? ed), only if sort has a working -z option. If you suspect that locate may need to return filenames containing newlines, consider using --null .

See

find, locatedb, xargs