Summary of Find command in Linux system

Source: Internet
Author: User


The Find command summarizes:

1) Search by name,find/-type f-name ' xiaoyao.txt ', Find and delete:Find/-type f-name ' xiaoyao.txt '-exec rm -f {} \; or:find/-type f-name ' xiaoyao.txt ' |xargs rm-f

2) Find files by modified time, such as last 5 days:Find/-type f-mtime-5,5 days ago:Find/-type F-mtime +5, Specify file:Find/-type f-name ' *.log '-mtime +5

3) Example: Find all in a directory and delete, but there is a file can not be deleted, the name is xiaoyao.txt.

[Email protected]]# find/mnt/python/seminar2/data/-type f!-name "Xiaoyao.txt"-exec rm-f{} \;

4) View the absolute path of the file:[[email protected]]# Find $PWD-nameett.txt

5) Look in the directory under the directory (only find the directory in this directory, not to findthe directory of subdirectories): Find./-maxdepth 1-type D,-maxdepthlevels Indicates the depth of the directory to find, in ...

6) find Middle add -o means or, for example:find./-type d-o-type F, add -and representation and, for example, find./-type d-a Nd-name ' xiaoyao* ' means to find the directory under the current directory and the name is Xiaoyao(do not write and represent and ),! non-such as section 3).

7) Delete method, add parameter-delete later , such as:find/-type f-name ' xiaoyao* ' –delete

8) query system files larger than 100M files :

[[email protected] logs]# Find/-type f-size +100m |XARGSLS-LH


Summary of Find command in Linux system

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.