How to use the Find command in Linux

Source: Internet
Author: User
Tags file size lowercase socket

There are two ways to find files:

First, locate: not real-time search, fuzzy matching, search based on system-wide file database; fast

# UpdateDB: is to manually generate a file database; fast

Second, find: real-time search, accurate matching, support a number of lookup standards, traversing the specified directory of all files to complete the search; slow

Use of the Find command

Find lookup Path Lookup standard lookup to later processing operations

Find path: Default view current directory

Find criteria: Default to all files under the specified path

Processing operations: Default to display

Its matching criteria:

-name ' filename ': exact Match of filename

FileName Wildcard:

*: Any length

?: any single character

[]: matches any single character within the specified range

[: Space:]: blank characters

[:p UNCT:]: Punctuation

[: Lower:]: Small Letter

[: Upper:]: Capital letters

[: Alpha:]: Uppercase and lowercase letters

[:d Igit:]: Digital

[: Alnum:]: Numbers and uppercase and lowercase letters

Example: # find/etc-name ' passwd* '--> find files that begin with passwd in/etc directory

-iname ' filename ': filename matching is case-insensitive

-regex pattern: File name matching based on regular expressions

-user USERNAME: Based on the owner lookup

Example: # find/tmp-user student--> Find files that are subordinate to the/tmp directory student

-group groupname: Find by group

-uid uid: Finding by UID

Example: # Find/tmp-uid 2003--> find files with a UID of 2003 in the/tmp directory

-gid GID: Lookup based on GID

-nouser: Find files that are not owned by the owner

Example: # Find/tmp-nouser--> Find files with no owners in/tmp directory

-nogroup: Find files with no group

-type: Find by File type

File type:

F: Ordinary Documents

D: Catalog Files

B: Block device files (blocks)

C: Character device file (character)

L: Symbolic link eh file (pipe)

P: Command pipe file (pipe)

S: Socket file (socket)

Example: # Find/tmp-type F--> Find common Files in the/tmp directory

-size: Find [+|-] based on file size

(11M is greater than 10M less than or equal to 11M)

# k

# M

# G

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.