The search for the text of the path of Linux learning---Use of the Find command

Source: Internet
Author: User

Text lookups can be implemented in two ways, using the locate command to find and find commands

So what's the difference between these two ways?

Locate: is a kind of non-real-time search, so-called non-real-time search is not practical, not accurate. Because the locate lookup is in

System file database, and the database is updated one day at a time, which means that the file you are looking for is re-database

Before the update, it is possible to find the file, because the database has not yet read the files on the hard disk, so

Some files are not written to the database.

You can receive the update database, using the command updatedb

Because it is not read on the hard disk, it is fast

Locate is a kind of fuzzy matching method

Because the locate use is not many, therefore only briefly introduced a bit.


Another way to find the file, use the Find command to locate (recursive lookup method)

Find command: Is a real-time lookup, he can accurately match a file, support a number of matching criteria, it is by traversing the entire directory

file to be searched, so it's slow

Syntax format: Find finds a path matching standard finds a later processing action

Find path: Default is current directory

Match criteria: Default is all files in the current directory

Handling actions: The default is to display the results on the screen


Matching Criteria:

-name file: Exact Match of file name ( you can also use filename wildcard to match file )

-iname file: Matching file names is case insensitive

-regex patttern: File name matching according to regular expressions

-user USERNAME: Find Files according to owner

-group GROUPNAME: Finding files According to the genus Group

-uid UID: Search for files based on UID

-gid GID: Search for files based on GID

-nouser: Finding files that are not owned by the master

-nogreoup: Finding files that are not owned by a group

-type Search by file type

-F Normal File

-D Catalog File

-L Link File

-C Character device file

-B Block Device file

-P Pipe File

-S Socket file

-size based on file size to find

[+|-] [#k | #M | #G]:+ represents greater than,-represents less than

Note: If you do not add + or-, it means that all matches within the [#k | #M | #G]


You can also combine matching criteria when matching conditions

-A: With relation

-O: or relationship

-not: Non-relationship

Match based on time stamp

-atime [+|-]#: Matches files according to the file's access time (in days)

-mtime [+|-]#: Matching files According to the time the file was repaired

-ctime [+|-]#: Match file According to file change time

+: Represents at least # days without [access | modify | change] Over

-: Indicates # days in [access | modify | change] too

Do not add + or-: Indicates exactly on # days [Access | modify | change] too


-amin: The meaning is the same, but the unit is minutes

-mmin:

-cmin:


-perm matching files according to permissions

MODE: Matches the file with the same permissions (exact match)

-mode: File permissions include this permission to meet the criteria

/mode: Just match a single permission in the file (nine-bit permission) to a successful match


Handling actions

-print: Display to screen

-ls: Displays details of this file in a form similar to Ls-l

-ok Command {} \; Use commands for found files (use this command to confirm)

-exec COMMAND {} \; ibid. {} refers to a file that was previously found



This article from the "Linux Learning Path" blog, declined reprint!

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.