


Now, suppose we do not know the complete filename but only the string of this file name. So the output will be only the specific file as mentioned above. Here, I have searched for a specific file ‘ath.html’ and not for the similar files to this string. find -iname Įxample: find /home/gaurav/tomcat -iname ath.html You can easily search for the files in any directory on the Linux system irrespective of the directory you are currently working in. Output will be the same, even if I have used the string in the upper case./context_log.policy Just make this simple change in your command and you will be fine. This allows you to search for the files irrespective of the cases in which their name is. You can simply replace the -name option with the -iname. Even if a single letter in the filename is in a different case than that of the original filename then, the search will fail.īut no need to worry about it. I will not get output for the find command if I use the string as ‘CONTEXT’ instead of ‘context’. Linux is pretty cautious about the case-sensitivity and hence, there’s a good chance that your search may fail. Now the problem arises with this command when you try to take the liberty about the case sensitivity whilst typing in the filename or the approximate string. This command searches for the files which contains the string ‘context’ in it.Īll the files in the current directory are listed which contains the string ‘context’ in it. To search for a file whose approximate name is known, use the find command as shown below. snap/htop/common/.local/lib/locale/en_IN.UTF-8/LC_CTYPE snap/htop/common/.local/lib/locale/en_IN.UTF-8 All the files present in this directory are listed without any filters Following is the output from my current working directory. This command will display all the files in your current working directory. Using the find command in its simplest form is to search for your files in your current working directory. This is the simplest demonstration for using the find command. Using the -name option allows me to search the file specified by ‘source.c’. I have asked specifically to search in the ‘/home/gaurav/workspace’ path.

In this command, I am using the find command to search for a file “source.c”. find /home/gaurav/workspace -name "source.c" Let us illustrate this command with an example. Options: You can use the available options used with the find command in this space.įind_what: In this attribute, put in the name or part of the name of the file to be searched. In short, the starting directory to start the search is specified.Įxpression: You can specify the search patterns for the particular file you are searching. Search_Path: Here comes the path where we specify the path from where we wish the system to start searching for the file. Let us look at each attribute of the syntax to get an idea of the significance of each of them. I have tried to simplify the syntax of the find command to understand the command better. The general syntax for the find command is as follows. Finding the files of particular type or extension or searching by the name will be possible if you understand the general syntax of this command well. Using the find command in a proper way can make your task easier. We will also learn about the locate command which is also a faster way to search for the files by name. We will look at the different arguments that can be used with the find command. In this tutorial, we will be focusing on finding the files by name. To make this task easier, Linux offers certain commands to do this job for you.įind is a popular command used in the Linux systems that can help you search for various files based on their names, type, extension, permissions, owner, etc. Finding it conventionally may be a time-consuming task. However, sometimes it becomes a very tedious job to find an individual file in the huge pile of files on your system. Users usually try to find a file using the GUI. Find your files effortlessly from the command line in Linux
