There are two invaluable commands that can be
used to find files on the filesystem: locate
and find. The locate command
is the easier of the two to use. Just type the command followed by part or all
of the filename you are searching for such as locate .odt to find all
OpenOffice.org text files or locate
compare to find all
filenames that contain the word compare. Notice that no wildcard
characters are used. It is assumed that what you type may only be part of the
filename you are looking for.
The only catch to this command is that it
relies on the generation of a database file so it can quickly display results.
The locate command is provided by the mlocate
package, which also provides the cron
script /etc/cron.daily/mlocate.cron to
automatically generate this database daily. If you are
looking for a file created that same day, it might not appear in the locate results
if the database hasn’t been updated since the file was created.
The find
command is a bit more complicated to
use and takes longer to produce results because it does not rely on a database
to produce results. Because it takes longer, it is possible to specify a
specific directory to look in. The basic syntax is as follows:
find
<directory> -name <filename>
Replace <directory>
with the directory to start looking
in. It will look recursively through the directory, meaning that it will look
in any subdirectories, subdirectories of the subdirectories, and so on. Replace
<filename> with the filename for which you are searching.
To search in the current directory and below, replace <directory> with a dot (.) character such
as:
find .
-name guidelines.txt
0 comments:
Post a Comment