Shell Command Learning

Source: Internet
Author: User
Tags version control system

The Find command is used primarily for file or directory lookups.

-print indicates that a matching file name is printed

-print0 indicates that each matching file name is printed using the ' \ \ ' delimiter

-name: Find by file name

-iname Ignore letter case

If you want to match one of several conditions, you can use the OR action:

-path matches the file path as a whole.

-regex: similar to path but matched based on regular expressions

! The meaning of negative parameters:

Search based on directory depth:

the Find command iterates through all subdirectories as it is used. Parameters -maxdepth and-mindepth can be used to limit the depth of traversal.

Search by File type:

Filter the file types with-type.

List all directories:-type D

List only ordinary files:-type f

List only Symbolic Links:-type l

Search by file time:

There are three timestamps in each file in the Unix/linux file system:

        1. Access Time (-atime): User last access time
        1. Modification Time (-mtime): The time the file content was last modified
        1. Change Time (-ctime): File metadata (metadata, such as permissions or ownership) time of last change

- represents less than,+ means greater than

FILE-size-based search:

Find files larger than 2KB :find-type f-size +2k

Units are:

B -Block( Kbytes)

C- Byte

W -word (2 bytes)

K -kilobyte

M- Megabyte

G -gigabyte

To delete a matching file:

-delete

Match based on file permissions and ownership:

-perm Permission Value

Let find skip a specific directory:

For example, in the version control system git to find a specific file when the skip . Git directory:

Find.−name". GIt"−prune -O−typef−print

which −n< Span id= "mathjax-span-38" class= "Mi" >am e " . gi t " −pr un e

to ignore a directory and the files under it, Use-prune;

−typef−print indicates the action that needs to be performed.

Shell Command Learning

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.