Find Files by
is basically used to look for files by name, or part of a name (hence the
option). By default,
is automatically recursive and searches down through a directory structure. Let's look for all MP3 files sung by the unique
the Shaggs on the music drive:
$ cd /media/music
$ find . -name Shaggs
What? This can't be correct! The
command found the folder, but not the songs. Why? Because we didn't use any wildcards,
named "Shaggs." There is only one item with that precise name: the folder that contains the songs. (Since a folder is a special kind of file, it's counted!)
We need to use wildcards, but in order to prevent the shell from interpreting the wildcards in ways we don't intend, we need to surround what we're searching for with quotation marks. Let's try the search again with our new improvements:
$ find . -name "*Shaggs*"
the wildcards with quotation marks; lo and behold, we found the folder and the files.
Another option to
that you've been using without
to list the results of its search on the terminal. The
option is on by default, so you don't need to include it when you run
Another important aspect of
is that the format of your results is dependent upon the path searched. Previously, we used a relative
, so our results were given to us as relative paths. What would happen if we used an absolute pathone that begins with a
$ find / -name "*Shaggs*"
If you search using a relative path, your results use a relative path; if you search using an absolute path, your results use an absolute path. We'll see other uses of this principle later in the chapter. For now, just keep this important idea in mind.
To find out more about the Shaggs, see www.allmusic.com/cg/amg.dll?p=amg&sql=11:qyk9kett7q7q, or just search www.allmusic.com for "Shaggs." You haven't lived until you've
"My Pal Foot Foot" at your