Use Find in Linux

Source: Internet
Author: User
Find the file mycprogram in the current directory and subdirectory. C # Find. -Name "mycprogram. C "Search for files without case sensitivity # Find. -INAME "mycprogram. C "Search does not contain mycprogram. c file find. -maxdepth 1-not-INAME "mycprogram. c"

 

Search for passwd # Find/-mindepth 3-maxdepth 5-name passwd in the subdirectories from Level 3 to level 5 under /.

 

Find and execute the command find.-INAME "mycprogram. c"-exec md5sum {}\;

 

Search for files larger than MB # Find ~ -Size + 100 m search for files smaller than M # Find ~ -Size-100 M: Search for files equal to M # Find ~ -Size 100 m

 

Find the maximum five files in the directory and subdirectory. -Type F-exec LS-s {}\; | sort-n-r | head-5: Find the minimum five files in the directory and subdirectory # Find. -Type F-exec LS-s {}\; | sort-N | head-5: Find the five files with a non-zero size and minimum size # Find. -Not-empty-type F-exec LS-s {}\; | sort-N | head-5

 

Find all files with write permissions for all users # Find.-Perm-G = W-Type F-exec LS-l {}\;

 

Find the files whose modification time is earlier than 5 days in the/logs directory and delete them $ find logs-type F-mtime + 5-exec RM {}\; search for Common files whose time is earlier than 7 days in the/var/logs directory, ask them $ find/var/logs-type F-mtime + 7-OK RM {}\ before deleting them {}\;

 

You can use a certain file name pattern to match the file. Remember to use quotation marks to cause the file name pattern. Otherwise, matching and expanding will cause confusion of the find parameter. $ Find.-Name [A-Z] *-printhttp: // www.linuxso.com/command/find.html

 

In the current directory, find the file with a permission of 755, that is, the file owner can read, write, and execute, and other users can read and execute the file. You can use $ find. -Perm 755-print

 

Http://yangdong.blog.51cto.com/2959198/546524

Http://www.cnblogs.com/itech/archive/2011/04/25/2027725.html

 

 

Complete!

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.