8-30 File Lookup command Find usage instructions and exercises

Source: Internet
Author: User
Tags glob

File Lookup:
The process of locating a qualifying file on a file system;

File Finder: Locate, find
Locate: A non-real-time lookup tool that relies on a pre-built index, which is built automatically when the system is idle (periodic tasks), manually updating this database (updatedb), searching fast, and fuzzy lookups;
Find: real-time search; search speed slightly slow; exact search;

Find command:
Command use format: Find [OPTION] ... [Find Path] [Search Criteria] [Handling Action]
Find path: Default to the current path;
Search criteria: The specified search criteria, can be based on the file name, size, genus of the main group, type, etc., by default to find all the files under the specified path;
Handling actions: What to do with the eligible files; By default, output to the screen;


1. Search Conditions:
(1) Search by file name:
-name "file name": Supports the use of glob;
*, ?, []
-iname "file name": Character case insensitive, supports use of glob;

-regex "pattern": matches the entire file path string with pattern, not just the file name;

(2) According to the genus, the genus Group looks for:
-user USERNAME: Find files belonging to the owner of the specified user;

-group GROUPNAME:

-uid UserID: A file that finds the owner-specified UID of a file;
-gid GroupID:

-nouser: Find files that are not owned by the master;
-nogroup: Find files without a group;

(3) Search by file type:
-type type
F: Normal file
D: Catalogue
L: Symbolic Link
B: Block device
C: Character device
P: Named Pipes
S: Socket

(4) Combination search criteria:
With condition:-A (can be omitted), find condition 1-a find condition 2-a ...: All conditions must be met
or condition:-O, find condition 1-o find condition 2-o ...: meet one and you can

Non-conditional:-not,!,-not Find condition: cannot be a lookup condition

! A-o! B =! (A-a B)
! A-a! B =! (A-o B)

(5) Based on the file size to find:
-size [+|-] #UNIT
Unit: K, M, G

#UNIT: (#-1,#]
+ #UNIT: (#,+oo)
-#UNIT: [0,#-1]

(6) Based on time stamp:
In "Days" as the unit
-atime [+|-]#
#:[#,#+1)
+#: [#+1,oo]
-#: [0,#]
-mtime
-ctime

In "Minutes" units
-amin
-mmin
-cmin

(7) According to the authority:
-perm [/|-]mode
MODE: Exact permission match
/mode: Any one of a class of objects (U,g,o) is eligible for any of the rights, implied or conditional;
/400
-mode: Every permission specified for each class of object must be in accordance with the condition;

2. Handling actions:
-print: Default handling action
-ls: Similar to the "ls-l" operation for each file found;
-delete: Delete the found file;
-fls/path/to/somefile: The detailed path information of the found file is saved to the specified file;

-ok COMMAND {} \;
The user must be confirmed beforehand before executing the specified command for each file;
-exec COMMAND {} \;
No user confirmation required;

8-30 File Lookup command Find usage instructions and exercises

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.