Searching files in Ubuntu : Ubuntu is free open source operating system. Ubuntu has both the Graphical User Inerface (GUI) and the command line interface (CLI). In this article we are going to tell you how you can search for files and directories on Ubuntu.
Ubuntu provides two main utility commands to search. You can also customize your search for more specific result with the help of wild card characters like '?', '*', [set] and [!set]. The following are the utility commands for searching :
1) locate : locate command will search all the files and directory which is having the specified searched string. For example if we need to search file or directory having the name 'test-file', the command is :
$ locate test-file
It will show all the files and folders which having the name 'test-file'. Now if we want to search all the files having extension '.pdf' then use following command ;
$ locate *.pdf
In case where you need to search file with caracter filter:
$ locate ?est.txt
Above command will search all files having the name ends with 'est.txt' followed by any character.
Now if the case is where you need to search files and folders which has bound between some characters like between 'a' to 'r'. for example 'best', 'rest' etc. It will not search string 'test'.
$ locate [a-r]est.txt
Above command will search all files having first character starts from 'a' to 'r'.
2) find : This is much specific command and more powerful to search files inside the specified folder. As compare to locate command which search files and folders in whole system, 'find' will search the files in specified folder. And you can also run other commands with the 'find' utility.
For example if you want to search the file and directory having name 'temp' inside the '/home' directory, then run following command :
$ find /home -name temp
If you want to search only for folders with the name temp use following command :
$ find /home -type d -name temp
If you want to search only for folders with the name temp use following command :
$ find /home -type f -name temp
0 Comment(s)