The "find" which you should kown

Source: Internet
Author: User

1. File Search:
Find eligible files on the file system
Related commands for file lookups:
Locate: Non-real-time lookup (based on index lookup in database)
Find: Real-time Lookup
2.locate command:
Dependent on the pre-built index: The index is built automatically when the system is idle (recurring tasks) and you need to manually update the database (command: updatedb)
The indexing process requires traversing the entire file system, consuming resources

Mode: Locate [OPTION] ... PATTERN ...
Locate KEYWORD
3.find command:
Real-time Find tool to complete file lookups by facilitating file system under specified path (if you do not restrict file types in advance, all type files are displayed by default)
Mode:
Find [OPTION] ... [Find Path] [Search Criteria] [Handling Action]
Find path: Specify a specific target path, default to the current path directory (including this directory itself)
Search criteria: The specified lookup criteria, can be file name, size, type, permissions and other standards; default to find all files under the specified path
Handling actions: What to do with the eligible files, output to the screen by default
1. Search criteria:
1). Search by file name:
-name "file name": Support for using Glob
*,? , [],[^]
-iname "file name": Letter case insensitive
-regex "pattern": matches the entire file path string with pattern, not just the file name
2). Depending on the owner, the genus Group looks for:
-user USERNAME:
-group GRPNAME:
-uid UserID:
-gid Grpid:
-nouser:
-nogroup:
3). Find by File type:
-type TYPR:
F
D
L
S
B
C
P
4). Combination Conditions
-A: With
-O: Or
-not: Non-
5). Find by File size
-size [+|-]# UNIT
Common units: K,g,m

#UNIT: (#-1,#]
-#UNIT: [0,#-1]
+ #UNIT: [#,oo]
6). Find by Time stamp
In "Days" as the unit:
-atime [+|-]#: # = [#,#-1]
+ #表示 [#+1,oo]
-#表示 [0,#]
-mtime [+|-]#
-ctime [+|-]#
In "Minutes" units:
-amin
-mmin
-cmin
7). Search by permissions
-perm [/|-]mode
MODE: Exact Match
/mode: (Meaning of "or") any class (U,g,o) object that has one match in the permission
-mode: (with meaning of "and") each class of objects must have both the permission criteria specified for it
2. Handling Actions
-print: Default processing action, display to screen
-ls: Similar to performing a "ls-l" command on a found file
-delete: Delete the found file
-fls/path/to/somefile: Long format information for all files found is saved to the specified file
-ok Command {} \: Executes commands specified for each file that is found and interactively asks the user to confirm each file before executing the command
-exec Command {} \: does not need to interact with the user to execute commands that are specified by the cmdlet for the found file.
(Note: Curly braces indicate the file name of the lookup itself)
Note: When find passes the found file to the command specified later, it finds all eligible files to be passed to the following instruction one time, and some instructions cannot accept too many arguments, at which point the command execution may fail
Another way to circumvent this problem
Find | Xargs COMMAND


This article is from the "Fante" blog, make sure to keep this source http://8755097.blog.51cto.com/8745097/1690275

The "find" which you should kown

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.