locate list files in databases that match a pattern

GNU version of locate.

updatedb

locate [-d path | --database=path]
[-e | -E | --[non-]existing]
[-i |--ignore-case]
[-0 | --null] [-c | --count]
[-w | --wholename] |-b | --basename]
[-l N | --limit=N]
[-S | --statistics]
[-r | --regex ]
[-P | -H | --nofollow]
[-L | --follow]
[-A | --all]
[-p | --print]
[--version]
[--help]
pattern...
For each given pattern, locate searches databases of file names and displays the file names that contain the pattern.
Patterns can contain shell-style metacharacters: *, ?, and [].
The metacharacters / or . are not treated specially. Therefore, the pattern foo*bar can match a file name that contains foo3/bar, and a pattern *duck* can match a file name that contains lake/.ducky.
Patterns that contain metacharacters should be quoted to protect them from expansion by the shell.

If a pattern is a plain string, it contains no metacharacters, locate displays all file names in the database that contain that string anywhere.
If a pattern contains metacharacters, locate only displays file names that match the pattern exactly. patterns that contain metacharacters usually begin with a *, and will most often end with one as well. The exceptions are patterns that are intended to explicitly match the beginning or end of a file name.

The file name databases contain lists of files that were on the system when the databases were last updated.
The system administrator can choose the file name of the default database, the frequency with which the databases are updated, and the directories for which they contain entries; see updatedb.

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

-A, --all Print only names which match all non-option arguments, not those matching one or more non-option arguments.

-c, --count display a count of matches , unless --print (-p) is present.

-d path, --database=path Search the file name databases in path, a colon-separated list of database file names. Use the environment variable LOCATE_PATH to set the list of database files to search. The option overrides the environment variable if both are used. 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.
-e, --existing Only print out such names that currently exist (instead of such names that existed when the database was created). This slows down the program a lot, if there are many matches in the database. It is possible for the file to be deleted after locate has checked that it exists, but before you use it.
-E, --non-existing Only display names that currently do not exist (i.e. the ones deleted since the database was built)
-L, --follow If testing for the existence of files (with the -e or -E options), consider broken symbolic links to be non-existing. default.
-P, -H, --nofollow If testing for the existence of files (with the -e or -E options), treat broken symbolic links as if they were existing files.

-i, --ignore-case

-l N, --limit=N Limit the number of matches to N. If a limit is set via this option, the number of results printed for the -c option will never be larger than this number.

-0, --null Use ASCII NUL as a separator, instead of newline.

-p, --print Print search results when they normally would not, because of the presence of --statistics (-S) or --count (-c).

-w, --wholename Match against the whole name of the file as listed in the database. default.

-b, --basename Results are considered to match if the pattern specified matches the final component of the name of a file as listed in the database. This final component is usually referred to as the base name.

-r, --regex The pattern is a regular expression, as opposed to a glob pattern. The Regular expressions work in the same was as in emacs and find, except for the fact that ". will match a newline.
Filenames whose full paths match the specified regular expression are displayed ( counted).
To anchor regular expression at the ends of the full path name, use the characters ^ and $ to .

-S, --statistics Display statistics about each locate database and then exit without performing a search, unless non-option arguments are given.

--help

--version

ENVIRONMENT LOCATE_PATH Colon-separated list of databases to search. If the value has a leading or trailing colon, or has two colons in a row, you may get results that vary between different versions of locate.

SEE find(1), locatedb(5), updatedb(1), xargs(1), iglob.

BUGS The locate database correctly handles filenames containing newlines, but only if the system's sort command has a working -z option. If you suspect that locate may need to return filenames containing newlines, consider using its --null option.

The best way to report a bug is to use the form at http://savannah.gnu.org/bugs/?group=findutils. The reason for this is that you will then be able to track progress in fixing the problem. Other comments about locate(1) and about the findutils package in general can be sent to the bug-findutils mailing list. To join the list, send email to bug-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

SEE find, locatedb, xargs

BUGS The updatedb program correctly handles filenames containing newlines, but only if the system's sort command has a working -z option. If you suspect that locate may need to return filenames containing newlines, consider using --null .