aidklion.blogg.se

Linux find directory by name
Linux find directory by name






linux find directory by name

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 For example, to search for a file named document.pdf in the /home/linuxize directory, you would use the following command: find /home/linuxize -type f -name document. It will look through its database of files and quickly print out path names that match the pattern that you have typed. To find a file by its name, use the -name option followed by the name of the file you are searching for. Or, to look for a filename or pattern from within the current directory, you can type: pwd | xargs -n 1 -I locate "filepattern"

linux find directory by name

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 As you know, Linux is case sensitive about file. For example, to search for a file named report.pdf in the /home directory, you would use the following command: find /home -type f -name report.pdf. To find a file using the filename, use the -name flag with the default command.

#Linux find directory by name how to

You should check the manual of your OS on how to install it, and once it's installed, it needs to initiate the database. The -type f option tells the system that we’re looking for a File. 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 To see the full list of options, type man find will search your entire home directory (likely where you downloaded it to). With the find command, you can use wildcards, and various switches. 9 Answers Sorted by: 363 Try find / -type f -name 'postgis-2.0.0' instead. It starts recursively traversing for filename or pattern from within the current directory where you are positioned. The default way to search for files recursively, and available in most cases is find.








Linux find directory by name