![]() These cron jobs need to be configured by root, since updatedb needs root privileges to traverse the whole filesystem. To see the full list of locate's options, type:Īdditionally, you can configure locate to update its database on scheduled times via a cron job, so a sample cron which updates the database at 1 AM would look like: 0 1 * * * updatedb It will look through its database of files and quickly print out path names that match the pattern that you have typed. You can use a variation of this command to find any file or directory. Or, to look for a filename or pattern from within the current directory, you can type: pwd | xargs -n 1 -I locate "filepattern" Youll typically use the find command with the syntax find /path -type f -iname filename. If the install script doesn't do it for you, it can be done manually by typing sudo updatedbĪnd, to use it to look for some particular file, type: locate filename ![]() You should check the manual of your OS on how to install it, and once it's installed, it needs to initiate the database. One such common tool is locate or slocate/mlocate. However, there are more modern and faster tools than find, which are traversing your whole filesystem and indexing your files. Or if man pages aren't available at your system: find -help For example, if you search your entire filesystem for the files named home.jpg: find / -name home.jpg More likely than not. Depending on the size of your file system and the depth of your search, the find command can sometime take a long time to scan all of the data. To see the full list of options, type man find Two popular commands for locating files on linux are find and locate. This is the starting point to search files. Where, /path is the path where file is expected to be found. Below is the basic syntax of the find command: find /path/ -type f -name file-to-search. Just search for file name matching Pictures, type: locate Pictures. ![]() To search for a folder named exactly dir1 (not dir1), type: locate -b dir1. With the find command, you can use wildcards, and various switches. The find command lets you efficiently search for files, folders, and character and block devices. Search folder in Linux using locate command. It starts recursively traversing for filename or pattern from within the current directory where you are positioned. 2 Answers Sorted by: 226 Try this command: find / -name file. The default way to search for files recursively, and available in most cases is find. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |