The Linux Find command

Source: Internet
Author: User

Linux is an "all-in-one" operating system, and the Find (find files) directive is especially important. The Find command searches the directory structure for a file and performs the specified action.

1. Command format:

Find Pathname-options [-print-exec-ok ...]

2. Command function:

Used to find files in the file tree and to make appropriate processing.

3. Command parameters:

Pathname: The directory path that the Find command looks for.

-print: The Find command outputs the matched file to standard output.

-exec: The Find command executes the shell command given by this parameter to the matching file in the form of ' command ' {} \;

-ok: The same as-exec, except that the shell command given by the parameter is executed in a more secure mode, prompting the user to determine whether to execute before executing each command.

4. Command options:

1) Find files by file name -name

2) find files by file permissions -perm

3) Find files by file owner and owning group -user-group

-user Search for files according to the owner of the file.

-group finds files according to the group to which the files belong.

4) Find files by file time -mtime-ctime-atime

-mtime-n +n The file changes time to find the file,-n means that the file change time is now less than n days, +n indicates that the file change time is now N days ago.

The Find command also has the-atime and-ctime options, but they are all similar to the-mtime option, so we'll just describe the-mtime option here.

5) Find files by file type -type

File types such as: B-block device files; D-directories; C-character device files; p-pipe files; L-symbol link files; F-common files; s-socket files.

6) Find files by file size -size N[c]

-size N[c] finds files with a file length of n blocks, with C indicating the length of the file in bytes.

7) search file depth by file -depth-maxdepth-mindepth

-depth when looking for a file, first find the file in the current directory, and then look in its subdirectories.

Description:find. -depth-name "File" –print it will first match all the files and then go to the subdirectory to find file.

In the root directory rating lookup:

-prune Use this option to have the Find command not be found in the currently specified directory, and if the-depth option is used at the same time, the-prune option will be ignored by the Find command.

Linux Find command

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.