Finding files and directories using the command line
Use the Find command (find) to locate files or directories on your hard drive. The shell searches your working directory by default. You can specify a different path name from which to begin searching. If the path name you want to search is located outside your working directory in the directory tree structure, use the directory's absolute path name. For information about absolute path names, see "Navigating the file system."
You can also set conditions to narrow the search. For a list of possible conditions, see the Manual page for the Find command. For example, using the Name condition (-name), you can search your home directory to find the file named file1.
Mabel~:$ find /home -name file1
You can use wildcards in conjunction with conditions. You can also redirect output from the search to a file, or pipe the output as input to another command. For information about using wildcards, see "Understanding wildcards." For information about redirecting output and piping, see "Redirecting input and output" and "Combining commands with pipes."
The following example uses the asterisk wildcard (*) to search the home directory for files with a .txt file extension.
Mabel~:$ find /home -name "*.txt"
You can add to the above command and redirect the output (files with a .txt extension) to a file named textfiles.
Mabel~:$ find /home -name "*.txt" > textfiles
To find a file or directory
1. At the command line, type,
find [<path name>] [<conditions>]
2. Press ENTER.
Notes
Do not include the brackets in the command line text. For information about notation conventions for commands, see "Using notation conventions for Linux commands."
If you use wildcards in your search condition, make sure to enclose the characters in quotes.
If you do not specify a path name or condition, the Find command displays the content of the current directory and includes the relative path name for each item.