What is find command?
The find command is used to search and locate the list of files and directories based on conditions we will specify. It can be used in verity of conditions like you can find files by permissions, users, groups, file type, etc.
$ find [where to start searching from] [expression determines what to find] [-options] [what to find]
- find. -name textfile.txt (Find a file called textfile.txt in current and sub-directories.)
$ find . -name textfile.txt ./textfile.txt
In the above example we learn that when we use find with name then it will show file path as a output.
2. find /home -name textfile.txt
This command is used to find the file textfile.txt inside home folder and its all subfolders.
$ find /home -name textfile.txt /home/myuser/textfile.txt
3. find /home -iname textfile.txt
In simple words if we are searching any file and we doesn’t know the exact name of that file (i.e it is in capital letter or in small letter) at that time we use -iname.
$ find . -iname Textfile.txt ./textfile.txt
$ find . -name Textfile.txt
In the above example we shown that when we write -iname with first letter capital(T) of Textfile then it will show us the file and when we write without -i then it doesn’t show the file path.