next up previous contents
Next: Moving files (mv) Up: Files and the File Previous: Setting and showing your   Contents

Finding files (find, locate)

Sometimes you will need to look for a file, but you aren't sure where it is. In this case, ls may not be very useful. The command you need is find. The syntax for find is quite awkward, so it will not be discussed in detail. Most of the time you will need to find a file which is somewhere underneath a particular directory. The easiest way to use find is to cd to that directory, and type:

malama% find . -name somefile -print

This will search everywhere in and under the current directory (``.'') for a file called ``somefile'', and print the pathname when it finds it. find can also look for other things; check the man page. In case you want to use the wild-card symbol ``'' in the filename, you have to preceed it with a backslash: $\backslash$.

At the JAC the GNU alternative to find has also been installed: locate. By default, locate searches system-wide and finds all file which have the given string as part of their filename. locate is much faster than find; read its manual page for more information.


next up previous contents
Next: Moving files (mv) Up: Files and the File Previous: Setting and showing your   Contents
h.stilmack@jach.hawaii.edu