The find command locates files based on characteristics such as the file name or type of file.
You can use find when you cannot remember where you stored a file. The following displays the find command.
find / -name petchip -print
The command above searches for files named petchip on the system. Since we start in the root directory, this searches the whole machine.
The above command will search every directory on your disk drives, and makes the disk drives work hard.
You may need to wait several minutes for the command to complete. This can be frustrating, so start your search in a directory other than root if possible. The next example starts in the /tmp directory instead of the root directory.
The –type and –user options
To locate a file by owner or file type, use the following command:
find /tmp -type f –user jane –print
Starting in the /tmp directory, this command searches for files that are type f (regular files as opposed to directory files) and owned by the user called jane. When the files are found they are printed onto the computer screen.
Here is a review of some common file types.
The next lesson shows how to use the wc command to count the words, lines, and characters in a file.