Documentation Reference Number: #0002
find
I. Arguments
List
Argument | Argument Options or Value | Description |
---|---|---|
-H |
Do not follow symbolic links; except while processing the command line arguments. | |
-L |
Follow symbolic links. | |
-P |
Do not follow symbolic links; this is the default. | |
-D |
Output diagnostic information. | |
exec |
Show debug information related to -exec, execdir, -ok, and -okdir. | |
opt |
Show debug information related to expression tree optimization. | |
-Olevel |
Controls the level of query optimisation. | |
0 |
This has the same effect as level 1. | |
1 |
The default optimization level. | |
2 |
-type or -xtype test are performed after any tests based only on the names of files. | |
3 |
This is fastest option, use this level when you want to run the find command as fast as possible. | |
-files0-from |
This command line argument should be used when you want to give the find command a file that lists the starting points rather than listing the starting points on the command line. | |
[ filepath ] |
The path to the file that contains a list of the starting points you would like to use. This can be either an absolute or relative pathname. |
II. How To Locate A File By Filename
Explanation
The find command is the best command to use when you want to locate a specific file or get a list of files which all match a particular pattern.
Example 1.1 demonstrates searching the entire linux system for a file named 'hosts'. The first argument is a forward slash '/', this indicates the directory where we want to start our search. The next argument is '-name' which tells the find command that we are looking for a file based on file name (rather than looking for a directory). The final argument is 'hosts' which is the name of the file we are searching for.
Example 2.1
Searching for a file named 'hosts' starting at the root directory '/'.john@comp:~$ find / -name hosts
Example 1.2 is basically the same as example 1.1 but we filter the search results through grep and remove any search results which include the text 'Permission denied'. So now are results include only matches to our 'hosts' query.
Example 2.2
Searching for a file named 'hosts' starting at the root directory '/'.john@comp:~$ find / -name hosts 2>&1 | grep -v 'Permission denied'
III. Ancillary Information
The examples provided on this page were generated on 2024-JULY-05 using the operating system Debian 12.6. The find program came installed with Debian by default.
Documentation Last Updated: 2024-JULY-26 at 2343 PDT.