Linux Find command usage Linux learning experience

Source: Internet
Author: User

Findcommand to locate a file under the specified directory, andLocatedifferent,Findcommands are real-time exact lookups, not fuzzy matches, but can be found using wildcard characters, which is relatively more accurate. Any string that precedes the parameter will be treated as the name of the directory you want to find. If you do not set any parameters when you use this command, theFindThe command will look up subdirectories and files in the current directory and display all the subdirectories and files that are found.

syntax Format:find [Find path ] [ find condition ] [ action after lookup ]

Find path: Specifies the specific search path, which defaults to the current path;

Search criteria: you can search by file name, size, permissions, date, and so on. If the condition is not specified, all files under the current path are implicitly considered;

the action after the search: actions made on qualifying files, such as delete, copy, are output to standard output by default.

Examples list:

1. list all files and folders in the current directory and sub-directory

Find.

2. Find the file name ending in. txt in the/admin directory

Find/admin-iname "*.txt"

3. Find files not ending with . txt under /admin

Find/admin! -name "*.txt"

4. Find all files ending in. txt and . pdf Under the current directory and sub-directory

Find. -name "*.txt"-o-name "*.pdf"

5. Matching file path or file

find/admin/-path "*user*"

6. Matching file paths based on regular expressions

Find. -regex ". *\ (\.txt\|\.pdf\) $"

7. Search for all files with a depth of at least 3 subdirectories from the current directory

Find. -mindepth 3-type F

8. Search for all files accessed in the last five days

Find. -type f-atime-5

9. Search All files that were visited five days ago

Find. -type F-atime 5

Search All files that have been accessed for more than five days

Find. -type F-atime +5

Search All files with access time exceeding 5 minutes

Find. -type F-amin +10

Delete all . txt files in the current directory

Find. -type f-name "*.txt"-delete

search for files with permissions of 777 in the current directory

Find. -type F-perm 777

Find the php file with permissions not 777 in the current directory

Find. -type f-name "*.php"! -perm 777

above is Find find files frequently used commands in the use of the Find command, you can refer to the above example!


Linux Find command usage Linux learning experience

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.