The use of the Find name order in Linux

Source: Internet
Author: User
Tags modifier

Find use of the command:

definition: Perform a real-time search on the local file system to find files that match the conditions of the command line parameters.

Use format: Find target file Match option match parameter

Find The first parameter is the directory to search for, and if the directory parameter is omitted, the Find The search starts from the current directory and finds matches in any subdirectory.

Find you can provide many options to accurately describe the type of file you should look for, and you can search by any combination of file name, file size, last modified timestamp, and other file attributes.

eg :

Find/-name sshd_config in the root directory and all subdirectories, search for the name Sshd_config of the file

Find/-name ' *pass* ' in the / etc any location in the search name in the directory contains Pass of the file

Find/-iname ' *messages* '-I. indicates ignoring case

Find you can search for files based on all permissions, and the options you can use are -user , -group , -uid , -gid wait

eg :

Find//home/student–user student in the /home/student Directory Search Student files owned by the user

Find//home/student–group student in the /home/student Search by Directory Student files owned by the group

Find/-user Root–group Mail

-perm option to find files with a specific permission set

  You can have / - symbols, With / / or - 0

eg :

Find/home–perm 644 The matching user has read and write permissions, the group member has reading permissions, and the other person has Read permissions

find/home–perm-724 match user has at least Read and write Execute permission, group member at least write permission, others have at least reading permission

find–perm-004

Find command to find a file that matches the specified size by -size option plus numeric values and units to specify

N : Equals N the size

+n : Greater than N the size

- N : Less than N the size

the units used with size are: k thousand bytes M Megabytes G gigabytes ( MBytes )

eg :

find–size 10M in the current directory, search size is 10M of the file

find–size +10m in the current directory, the search size is greater than 10M of the file

find–size-10m Search size Under current directory is less than 10M of the file

-size the unit modifier takes all the content up to one unit, such as find-size 1M will show less than 1MB file, because it takes all the files up to 1MB

-type option to limit the search scope to the given file type, type has

F : Normal file

D : Directory

L : Soft links (Symbolic links)

b : Block Device

eg :

Find/etc–type F Search / etc all ordinary files under the directory

Find/etc–type D Search / etc all directories in the folder

Find/etc-type L Search / etc all symbolic links in the directory

Find/dev–type b Search / Dev List of all devices in the directory

-mmin option plus the time in minutes to search for all the files that have changed in the past given time,

similar to -amin,-cmin .

m represents a modification Modify , min represents minutes, a represents access, C represents the Creation

-mtime Options in days, a similar -ctime , -atime

eg :

Find/-mmin The search is exactly the same as the modified time - minutes of File

Find/-mmin +200 will find the $ all files that were changed before minutes

Find/-mmin-150 less than the modified time of the search Max minutes of all files

-links The option Plus number will find all files with a specific number of hard links, preceded by a Suzi + modifier will find the number of hard links more than the given number of files, if the number preceded by a ~ modifier, the search will be limited to all files that have fewer hard links than the given number.

eg :

Find/-type f–links +1 root directory search hard link number greater than 1 all the ordinary files

Complex usage: You can perform additional operations on the searched files

eg :

find/usr/bin–size +50k–exec cp {}/tmp/bin \; Search /usr/bin/ the size of the directory is 50K all files and copy them to /tmp/bin directory under

Find/usr/bin–type f–exec rm–rf {}\; Search for all normal files in the/usr/bin directory and perform a delete operation on it


The use of the Find name order in Linux

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.