Find for Linux Commands

Source: Internet
Author: User
& Amp; 65279; & amp; 65279; search File & amp; 26684; type findpathoption [-print] [-exec-okcommand] {} the default search path is-print, output to the standard output. execute the command option to search for objects found.

Function

Search for files

Format

Find pathoption [-print] [-exec-OK command] {}\

The default search path is the current path.

The default value is-print, which is output to standard output.

Execute the command for the searched file

Option is a search condition.

Main parameters

-Name filename

Restrict file names

-User username

Search by file owner

-Group groupname

Search by group

-Mtime-n + n

Search by file change time,-n refers to n days or less, + n refers to n days before

-Atime-n + n

Query by file access time

-Ctime-n + n

Search by file creation time

-Nogroup

-Nouser

-Type

Search by file type

-Size n

-Depth

Search the local directory before searching for the subdirectory

-Follow

If a symbolic link file is encountered, the file indicated by the link will be tracked.

-Prune

Ignore a file

-O

Logic or

-

Logic and

!

Logic no

\(\)

Escape, including search conditions

Example

Find all common files in the current directory

Find.-type f-exec ls-l {}\;

In the home directory, find and delete files whose changes were earlier than 5 days.

Find/home-mtime + 5-exec-OK rm {}\;

Query the files modified today

Find/-mtime-1-exec ls-l {}\;

Query the modified files today and prompt whether the files are displayed.

Find/-mtime-1-OK ls-l {}\;

Search for files smaller than kB and display them

Find/home-size-100 k-exec ls-l {}\;

Search for all files suffixed with. txt.

Find ~ -Name "*. txt"-OK ls-l {}\;

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.