Locate reads one or more databases prepared by updatedb command.
Options
/----------------------------------------------------------------------------------------------\
| |
| -n x | List only the 1st X matches |
| -i, ignore-case | Ignore case distinctions when matching patterns. |
| -b, basename | Match only the base name against the specified patterns. |
| |
\-----------------------------------------------------------------------------------------------/
Examples
find command
Find - Searches Directory Trees In Real Time
Slower But More Accurate Than Locate
CWD Is Used If No Starting Directory Is Given
All Files Are Matched If No Criteria Is Given
Examples:
Logical Operators
If multiple criteria are given to the find commands:
All criteria are ANDed together by default.
This behavior can be overridden with the -or or -not(!) options.
Operator Precedence
\( Expression… \)
The Logical Not(-not, !)
The Logical And(-and, -a)
The Logical Or(-or, -o)
NOTE!: \( Expression… \) Force Precedence, Include space after the \( and before the \)
Examples:
Force Precedence
Find And Permissions
/-----------------------------------------------------------------------------------------------------\
| |
| -perm mode | File’s permission bits are exactly same as the mode. |
| -perm -mode | File's permission bits are atleast contain the mode + Extra Mode |
| -perm /mode | Any of the permission bits mode are set for the file. |
| |
\-----------------------------------------------------------------------------------------------------/
Examples:
Find and Numeric Criteria
Many Find Criteria Take Numeric Value Such As
/-----------------------------------------------------------------------\
| |
| -size: | The size of the file (k=KB, M=MB, G=GB) |
| -links: | Number of links to the file |
| |
| -amin: | When the file was last read |
| -mmin: | When the file data last modified |
| -cmin: | when the file data/metadata last changed |
| |
| -atime: | When the file was last read |
| -mtime: | When the file data last modified |
| -ctime: | when the file data/metadata last changed |
| |
\-----------------------------------------------------------------------/
Examples:
NOTE!: Use stat command to display files time stamps.
Find Can Also Execute Commands On The Found Files By Using The Following Options
/-----------------------------------------------------------------------\
| |
| ok | Prompts Before Acting On Each Found Files |
| exec | Runs The Commands Without Any Prompts |
| |
| {} | File Name Placeholder |
| space\; | Terminate Command |
| |
\-----------------------------------------------------------------------/
For Example:
The Gnome Search Tool
The Gnome search tool is accessed via Places -> Search for Files…
The Gnome search tool only look at the user’s home directory by default.
The Gnome search tool uses the find command in the background, But not have all the find features.
Newsletter
Get updated when I create new content. Unsubscribe whenever. Never any spam.
Note
I'm Tama. I turn down every ad, affiliate, and sponsor request I get. I write free resources that help people. If you enjoy my content, please consider supporting what I do.