Locate and find: find file commands in two Linux systems
Source: Internet
Author: User
Locate and find: find file commands in two Linux systems-general Linux technology-Linux technology and application information. The following is a detailed description. If you want to execute a file search task on the command line interface for the first time switching to Linux, you need to know the commands locate and find. Although both of these commands can be used to search for files, they have their own advantages.
Locate: This Command requires the database indexed in the background to support running. In Ubuntu, the database file is located in/var/cache/locate/locatedb. Generally, this database file is automatically updated through cron every day. If the update is unfortunately not obtained, You can execute sudo updatedb to manually update the update.
If you want to find a file named linux.html in the system, you can execute the command: locate linux.html. The locate search speed is very fast, and the results will be listed later. Locate has a very useful option-r, which allows you to use regular expressions when searching for files.
Find: this is an important file search command in another Linux system. The find command is very powerful. It is generally used as the name of the find location-name file. For example, if you want to find the linux.html file in the/root directory, you can run find/-name linux.html. In addition to searching for files by file name, you can also use the-size n option to specify the file size), time (for example,-atime n indicates to search for files accessed n days ago) to search for files.
In addition, the find command also supports regular expressions when searching files. You only need to specify the-regex option.
It is worth noting that the explanation of the two commands locate and find is far from satisfying this small article. For more detailed usage of these two commands, you may need to query them by man locate or man find.
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.