Using any Linux desktop manager there are many ways of finding the files and folders. Some of the methods are provided.
Using find command:
If you know the approximate name of a file ‘find’ command will help you in the locating the file. This command is used for searching a file name in the current directory and in its sub directories which matched the provided criterion. File name can be searched by its name, owner, date, type and using some other criteria.
To find all the files in the current directory, type the following command
The dot after command represents the current directory.
If we are required to find the files which matches a specific pattern, use the ‘-name’ argument. Metacharacters like “*” can also be used with file names. But you must put escape character (“\”) in fornt of them or they can be enclosed in the quotes.
To find all the files prefixing pro, we will type the following command
find . –name pro\*
after pressing the Enter key, all the files that are starting with the word pro will be listed.
The command find is case sensitive by default. If we want to search a particular word or phrase to be case insensitive. Replace the word name with the iname. It is the case insensitive version of name.
If in some directory no file is found matching your criteria, no output message will be displayed. For a refined search many search options are available with find command.
Using the locate command:
This command shows a faster performance than that of find command because it is based on previously built database. Passing through all the present files and folders find command searches in real system. ‘Locate’ command returns all path names which contain the given group of character.
The database updates automatically. It also has the options that you can update the database yourself any time and find the result which will be more time saving. To update following command is used
If it prompts enter your password.
The locate command search files through all the file systems. It starts from the base and shows all or any part matching the criteria.
this can show files named as mydata and also containing the word data.
If you desire to find the name which strictly matches your searching criteria, use ‘-b’ with the locate command.
locate –b ‘\mydata’
the backslash used is the globbing character.
Wildcard which are most commonly used are ‘?’ for the single character and ‘*’, for the contiguous string of character.
The command mlocate is a new implementation of the locate. It only shows those files which the current user have access. When the database of the mlocate is updated, it also includes timestamp information in the database.
If the mlocate is no already included in your Linux Distribution, you can add it by typing the following command.
Sudo apt-get install mlocate
Mlocate does not uses the same database file as of locate.