If desired, use wild cards to specify lenames. The program is very quick, because
it uses a database specically created for the purpose (rather than searching
through the entire le system). This very fact, however, also results in a major
drawback: locate is unable to nd any les created after the latest update of its
database. The database can be generated by root running updatedb.
find
With find, search for a le in a given directory. The rst argument species the
directory in which to start the search. The option -name must be followed by a
search string, which may also include wild cards. Unlike locate, which uses a
database, find scans the actual directory.
grep
The grep command nds a specic search string in the specied text les. If the
search string is found, the command displays the line in which searchstring was
found, along with the lename. If desired, use wild cards to specify lenames.
17.8.1 Examples for Searching
The KDE and GNOME desktops store user-specic application data in hidden direc-
tories, for example .kde and .gnome.
1 To locate these directories on your computer, enter
locate .kde
if you have installed KDE desktop or
locate .gnome
if you have installed GNOME desktop.
You will see that locate displays all le names in the database that contain
the string .kde or .gnome anywhere. To learn how to modify this behavior refer
to the man page of locate.
2 To search your home directory for all occurrences of lenames that contain
the le extension .txt, use
find ~ -name '*.txt' -print
3 To search a directory (in this case, your home directory) for all occurrences
of les which contain, for example, the word music, enter
grep music ~/*
Note that grep is case-sensitive— unless you use it with the -i option. With
the command above you will not nd any les containing Music.
210 Start-Up