File Lookup:
To find eligible files on a file system procedure:
File Lookup tool:
Locate: Non-real-time lookups (dependent on pre-built index lookups, which are automatically updated when the system is idle (recurring tasks); The user can manually update this index (UPDATEDB))
Advantages: The search speed consumes less resources; Fuzzy Lookup: Can be found as long as it contains conditions
Cons: The latest files can not be found, real-time is not high
Find: Real-time lookup (by traversing the specified path)
Pros: Exact lookup of file names
Cons: Slow Lookup
Find command
Find "option" ... Find path "find condition" "Process action"
Find path: Default to Current path
Search criteria: Specify the criteria for finding, can be based on file name, size, attributes, etc., by default find all files under the specified path
Handling actions: Actions on qualifying files, output to screen by default;
Search criteria:
To find by file name:
-name "file name" supports the use of glob (*,? , [])
-iname "file name" is case-insensitive and supports the use of glob;
-regex "pattern" matches the entire file path string with a regular expression, not just the file name;
Search by Owner
-user USERNAME: Find files with user name specified
-group GROUPNAME:
-uid USERID: Find files for the owner-specified UID of a file
-nouser: Finding files that are not owned by the master
-nogroup
Find by File type:
-type type
F: Normal file (in LS-indicated)
D: Catalogue
L: Symbolic Link
B: Block device
C: Character device
P: Named Pipes
S: Socket
Combination Lookup criteria:
and Conditions:-A
or condition:-O
Non-conditional:-not,!
Find/tmp \ (-nouser-o-nogroup\)-ls
-ls processing is for the () condition () required \ Translator Number if not added only for-nogroup condition
To find by size:
-size "+|-" #UNIT
#UNIT: Indicates greater than #-1 and less than or equal to #
-#UNIT: Indicates less than or equal to #-1
+ #UNIT: Indicates greater than #
Find by Time stamp:
In "Days" as the unit
-atime "+|-" #
#: "#,#+1")
+: "#+1,∞"
-: (0,#)
-mtime
-ctime
In "Minutes" units
-amin
-mmin
-cmin
Based on permissions:
-perm "/|-" MODE
MODE: Exact Match
/mode: Any one of a class of users with the right to meet the criteria
For example/666: The master has Read permission or write permission or the group has read or write permissions or other users have read or write permissions
-mode: The permissions specified for each class of user are eligible
For example-420: The owner must have read permission and belong to the group write permission other users do not request
0 indicates no permission requirements for the class of users
Handling actions:
-print: Default handling action
-ls: Similar to "ls-l" Operation for locating files
-delete:: Delete the found file:
-fls/path/to/somefile: Found file detail path information saved to the specified file
-exec COMMAND {} \; #不会提示确定, direct operation
-ok COMMAND {} \; #会提示确定, direct operation
Note: The Find command finds all eligible files one at a time and passes them along to the following commands, but some commands cannot accept too long parameters, workaround: Find |xargs command
Find detailed use of files