Locate search fast and full command English intent
Command format
Command function
The locate command can quickly find the file when searching the database, the database is updated by the UpdateDB program, UpdateDB is created periodically by Cron Daemon, and the locate command searches the database faster than the entire data from the hard disk. But the worse is locate found the file if recently established or newly renamed, may not be found, in the default value, UpdateDB will run once a day, can be modified crontab to update the set value. (Etc/crontab)
Locate is used to search for eligible files, it will go to the database to store files and directory names, find files or catalogs that conform to the template style criteria, you can use special characters (such as ”*”
or, ”?”
etc.) to specify the template style, as specified in the template kcpa*ner
, Locate will find all the files or directories that start with a string of KCPA and end with NER, such as Kcpartner, if the directory name is Kcpa_ner, all files that include subdirectories are listed in that directory.
Locate command and find find files similar function, but locate is through the update program to the hard disk all the files and directory data first set up an index database, in the execution of LOACTE directly to find the index, query faster, the index database is generally managed by the operating system, However, you can also directly release the update to force the system to immediately modify the index database.
Common parameters
-e
will be excluded from the scope of the search.
-1
If it is 1. The security mode is started. In safe mode, the user does not see files that the permissions cannot see. This slows down because the locate must get access to the file in the actual file system.
-f
To exclude specific file systems For example, we have no reason to put the files in the proc file system in the database.
-q
Quiet mode, no error messages are displayed.
-n
Displays at most n outputs.
-r
Use regular expressions to find the conditions.
-o
Specifies the name of the data inventory.
-d
Specify the path to the repository
-h
Show auxiliary messages
-V
Displays the version message of the program
Common Example Example 1
Search all files in the ETC directory that begin with SH
locate /etc/sh
Example 2
Find all JPG files under/usr/share/
locate /usr/share/\*.jpg
Note To add a backslash escape before the * number, otherwise it will not be found.
Linux File Management Locate