|
9 | 9 |
|
10 | 10 | ## <a name="find"></a>find
|
11 | 11 |
|
12 |
| ->search for files in a directory hierarchy |
| 12 | +```bash |
| 13 | +$ find --version | head -n1 |
| 14 | +find (GNU findutils) 4.7.0-git |
| 15 | + |
| 16 | +$ man find |
| 17 | +FIND(1) General Commands Manual FIND(1) |
| 18 | + |
| 19 | +NAME |
| 20 | + find - search for files in a directory hierarchy |
| 21 | + |
| 22 | +SYNOPSIS |
| 23 | + find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] |
| 24 | + [expression] |
| 25 | + |
| 26 | +DESCRIPTION |
| 27 | + This manual page documents the GNU version of find. GNU find searches |
| 28 | + the directory tree rooted at each given starting-point by evaluating |
| 29 | + the given expression from left to right, according to the rules of |
| 30 | + precedence (see section OPERATORS), until the outcome is known (the |
| 31 | + left hand side is false for and operations, true for or), at which |
| 32 | + point find moves on to the next file name. If no starting-point is |
| 33 | + specified, `.' is assumed. |
| 34 | +... |
| 35 | +``` |
13 | 36 |
|
14 | 37 | **Examples**
|
15 | 38 |
|
@@ -74,7 +97,29 @@ Passing filtered files as input to other commands
|
74 | 97 |
|
75 | 98 | ## <a name="locate"></a>locate
|
76 | 99 |
|
77 |
| ->find files by name |
| 100 | +```bash |
| 101 | +$ locate --version | head -n1 |
| 102 | +mlocate 0.26 |
| 103 | + |
| 104 | +$ man locate |
| 105 | +locate(1) General Commands Manual locate(1) |
| 106 | + |
| 107 | +NAME |
| 108 | + locate - find files by name |
| 109 | + |
| 110 | +SYNOPSIS |
| 111 | + locate [OPTION]... PATTERN... |
| 112 | + |
| 113 | +DESCRIPTION |
| 114 | + locate reads one or more databases prepared by updatedb(8) and writes |
| 115 | + file names matching at least one of the PATTERNs to standard output, |
| 116 | + one per line. |
| 117 | + |
| 118 | + If --regex is not specified, PATTERNs can contain globbing characters. |
| 119 | + If any PATTERN contains no globbing characters, locate behaves as if |
| 120 | + the pattern were *PATTERN*. |
| 121 | +... |
| 122 | +``` |
78 | 123 |
|
79 | 124 | Faster alternative to `find` command when searching for a file by its name. It is based on a database, which gets updated by a `cron` job. So, newer files may be not present in results. Use this command if it is available in your distro and you remember some part of filename. Very useful if one has to search entire filesystem in which case `find` command might take a very long time compared to `locate`
|
80 | 125 |
|
|
0 commit comments