Find Command Quick entry

Source: Internet
Author: User
Find Command Quick entry 1. Want to see if there is a file named "ABC" in the current folder and subfolders
Find. -name ABC

 .: Represents the current directory
-name: means to find by name
2. Want to see if there is a "xyz" directory in the current folder and subfolders
Find. -type d-name xyz

-type: Indicates a set type, D represents a folder type, can be replaced with F (normal file), L (linked file)
3. Want to find out the current folder and subfolders of all suffixes are ". h" or ". cpp" Files
Find. -name "*[.h|. CPP] "-type f

or: Find

.-name" *.h "-o-name" *.cpp "
4. Want to find the current directory and its subfolders of the "ROC" Users own files what
Find. -user Roc

-user: Used to set the name of the owning user, which can be replaced with-group, which is the name of the owning user group
5. To find all files with permission set to 755 in the current folder and subfolders
Find. -perm 755

-perm: for setting permissions
6. To find the file name in the current folder and subfolder containing both B-and 3-character files, using regular expression techniques
Find. -regex '. *b.*3 '

 -regex: Indicates that a regular expression is used to match. Note that this command matches the "full path", which means that you want to precede the. *, because there will be a "./" symbol in the output result.
7. If you want to output the contents of the "*.abc" file found using the Find command
Find. -type f-name "*.abc"-exec cat {} \;

-exec indicates that matches found by find can be used-ok instead of-exec as a "-exec command" parameter
, so that for each match, the user will be asked to confirm (Y is, n is no)
Note: command the last "{} \;" Don't forget to write, where {} represents each lookup item in the result found with find, {} and \ with a space and ending with a colon.
8. Find files that have been accessed in the current directory within 5 minutes
Find. -amin-5

visited with Amin, modified with mmin, file status changed with Cmin
accurate to minute with amin,mmin,cmin, accurate to the day with Atime,mtime,ctime within
5 minutes of Use-5, In more than 5 minutes with +5
9. To find all files with a file size greater than 10M in the current directory and subdirectories
Find. -size +10000000c

-size: Indicates file size, + indicates greater than a number,-represents less than a number. C means the unit is byte, you can change C to k,m,g.
10. All of the Find commands above are looking for the current directory and its subdirectories. If you do not want to drill down into subdirectories, but instead find the current level of directories, you can:
Find. -maxdepth 1-name "*.C"

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.