How to search and process instances in Linux

Source: Internet
Author: User
1. Locate: Locate [Option] keyword Query the files matching the search criteria in the file database. Option: -I: Whether the search is case sensitive. The default value is case insensitive; -N x : Display only before X Matching items; Note: * The file database is used by administrators. Updatedb Otherwise, the newly created files cannot be found. Generally, the database automatically creates updates in the background. * Search for full paths, not just file names. 2. Find: Find [directory…] [Condition……] It is slower than the locate command, but more accurate; * If no directory is specified, query in the current directory; * If no conditions are specified, all conditions are matched. You can run the following command on the file: select-OK or-exec. 1. Basic conditions: 1) -Name File Name: Find the matching file name;

2) -User User name: search by user name; -UID User ID: search by uid; 3) -Group Group Name: search by group name; 2. Conditional logical operations: The and quick connector is used by default for search conditions; Find/-name Ook-user RedHat is a file that meets the requirement that the file name is ook and belongs to the RedHat user. 1) -O To perform or operations; 2) -Not : Logical non-operation:

3. Permission-related search :-Perm [+/-] digital permission 1) + Digital permission : Indicates that at least one character is met; 2) -Digital permission : Indicates that all digits match: 4. Search by file size :-Size [+/-] File Size Find-size 1024 K The file size is exactly 1 MB. Find-size + 1024 K file size greater than 1 mfind-size-1024 K The file size is smaller than 1 MB. 5. Search by access time: -Atime The last read time; -Mtime Last modification time of file data; -Ctime File status change time;-atime-mtime-ctime unit: Days If you want Minutes Can be written -Amin-mmin-Cmin Find-mmin-10 search for files with a modification date of less than 10 days; 6 And find file processing: 1 ) -OK : Confirm when executing the command; 2) -Exec : No confirmation is required to directly execute the command. Remarks: {} Indicates the file name found; Space and \; Indicates termination. Of course, the find command has many combinations. Article This gives you more familiarity with the use of find and more combinations.
Related Article

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.