Penn Engineering CETS Answers

How to use "find" to find files

If you have lost a file, there is a command "find" which will search for it. For example, let's say that you got a mail message, and you are pretty sure that you saved it as "susan.mail" or "susan.message" or "from-susan". You don't know which sub-directory it is in, and you want to find it.

% find ~ -name '*susan*' -print
will search everything under your home directory (~) and print out any files with the word "susan" in it's name. It won't find "Susan", though, because upper and lower case are distinct in Unix.

The pattern '*susan*' means "anything followed by susan followed by anything". The quotes keep the shell from doing file matching on the "*"s.

Find has many options, and can do very complex searches. See "man find" for more information.

Please do *not* try to find software on Eniac by running

% find / -name whizbang -print
When someone does this, a number of things happen:

  1. A lot of CPU time is used looking in places that couldn't possibly have any commands. The CPU and disks get tied up, and system performance drops for everyone.
  2. Eventually you hit the home directories. Find now checks 2400 directories to tell you that you don't have permission to read them.
  3. Then, find hits the home directories mounted from Grad1, Gradient, Unagi, and Saul. So, you still spend lots of energy just to find out that you don't have permission, but now you are tying up all these machines, and increasing network load.

On Eniac and other CETS machines, using find is not an appropriate way to find software.

 

© Computing and Educational Technology Services cets@seas.upenn.edu 215.898.4707