Article Title: Use slocate to find the file. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
When searching files, most users use the "the which" command as the first command. However, such commands only apply to files included in the user path. If a file is not in the user's path, the "the which" command will not find the target file.
The next option is to find the command itself, but it is very killing. In this way, it takes time to search for the content that matches the required standard in each directory and file. If you have some permission or ownership to search for a file, this is quite good, but it is quite time consuming to search for a specific file by name.
Another option is the slocate command, which is the standard of most Linux vendors. This command is used to search for files through the database and update at night using cron job.
After slocate is installed, you must create the database to search. The database creation time varies depending on the size of your file system.
Run the following command to initialize the database:
# Slocate-c-u
After creating the database, create a cron job and run slocate (as shown above) every night to update the database.
Run the following command to find the file:
$ Slocatemyfile
Regardless of the location of the file in the system, this command can find the "myfile" file. If a similar file exists, such as "myfiles" or "test-myfile", the command also finds these files.
You can send many options to this command. You can also use slocate to perform file search by passing it a regular expression. You can also perform fuzzy search, and you can limit the number of returned results.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service