There is two most widely used file searching utilities accessible to users are called find and locate. The Linux locate command comes paired with its partner updatedb. The locate command allows you to locate files that contain your searching criteria and displays them out for you. The updatedb partner it has is what keeps the locate command up to date on the files in your system. The main difference between the two is that grep is used to search for a particular string in a file whereas find is used to locate files in a directory, etc.
Thus, locate is much faster than find , but can be inaccurate if the database -can be seen as a cache- is not updated see updatedb command. The locate command is used to find files by their filename. The locate command is lightning fast because there is a background process that runs on your system that continuously finds new files and stores them in a database. Type the command in the chat window and Press the Enter key to run the command.
Finding files by name is probably the most common use of the find command. To find a file by its name, use the -name option followed by the name of the file you are searching for. Find command is used to search and locate the list of files and directories based on conditions you specify for files that match the arguments.
There is two most widely used file searching utilities accessible to users are called find and locate. The type command is used to describe how its argument would be translated if used as commands. It is also used to find out whether it is built-in or external binary file. A locate command finds files faster because it searches a database instead of having to search the whole filesystem live. A dis-advantage is that the locate command cannot find any files added to the system since the previous time the database was created.
The database is optimized for searching. Skip to content Android Windows Linux Apple. Home » Apple. What is the difference between 'locate' and 'find' in Linux?
Ask Question. Asked 11 years, 1 month ago. Active 2 years, 3 months ago. Viewed 52k times. Improve this question. Bessa 3 2 2 bronze badges. Add a comment. Active Oldest Votes. In any case, man find and man locate will help you further.
Improve this answer. When you execute locate , it'll use that database to search for a particular file. The problem with locate is if you just created a file which you now want to search for, locate will not work because the slocate database is not up-to-date. To overcome this problem, you can use updatedb to update the slocate database. Executing locate again will now find the newly created file.
Thus, many Linux system administrators use a cron job to regularly update the slocate database. It will actually go and search all the directories to find the particular file specified and it examine each file one-by-one. So based on the nature, it is clear that locate is faster than find but find is real time. Hope this will help to clear the idea.
0コメント