linux--Learning Chapter (ii) of the Find command

Source: Internet
Author: User
Tags readable uppercase letter

The Find command in Linux:

For Linux, there is a " everything file " feature, so it is not easy to find a file without a suffix compared to Windows. Therefore, we need to familiarize ourselves with the Find command under Linux to find the files we need faster.

1. Command format

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

2. Command parameters

The directory path that the Pathname:find command looks for. For example, use. To represent the current directory, and to represent the system root directory.

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

The-exec:find command executes the shell command given by the parameter to the matching file.

-ok: As with-exec, a prompt is given before each command is executed, allowing the user to decide whether to execute it or not.

3. Command options

(1)-name find files by file name.

Find all the matching log files in the $home directory.

Find ~-name "*.log"-print

To find all the ' *.log ' files in the current directory and subdirectories:

Find. -name "*.log"-print

You want the current directory and subdirectories to look for files with a file name that begins with an uppercase letter:

Find. -name "[a-z]*"-print

To find files with the file name beginning with host in the/etc directory:

Find/etc-name "host*"-print

To find files in the $home directory:

Find ~-name "*"-print or find. -print

To get the system running at a high load, start looking for all the files from the root directory:

Find/-name "*"-print

If you want to find the file name in the current directory starting with a lowercase letter, the last file that is 4 to 9 plus. Log Ends:

Find. -name "[A-z]*[4-9].log"-print

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/80/4F/wKioL1c9sWHTZKm2AADHyB7hHzQ872.png "title=" Untitled. png "alt=" Wkiol1c9swhtzkm2aadhyb7hhzq872.png "/>

(2)-perm follow the file permissions to find the file.

Example: Find user as a readable writable executable, group for readable writable, and other as readable non-writable (764):

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/80/51/wKiom1c9s1CAV9nzAACjJdtM0AM378.png "title=" Untitled. png "alt=" Wkiom1c9s1cav9nzaacjjdtm0am378.png "/>

(3)-prune Use this option to make the Find command not be found in the currently specified directory, and if you use the-depth option at the same time,-prune will be ignored by the Find command.

Example: Find a file under the test directory, but do not want to find it in the Test/test directory

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/80/52/wKiom1c9t66xa6VqAABH3C89Vno113.png "title=" capture. PNG "alt=" Wkiom1c9t66xa6vqaabh3c89vno113.png "/>

(4)-user search for files according to the owner of the file.

Example: Finding files in the $home directory where the file belongs to the master Root/sust

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/80/52/wKiom1c9vAexXP9QAABBaLnKO7c711.png "title=" Untitled. png "alt=" Wkiom1c9vaexxp9qaabbalnko7c711.png "/>

(5)-group find the file according to the group to which the file belongs.

-nogroup Find all files that do not have a valid owning user group

In the current directory, look for files that belong to the root user group and the root directory of the file system to find all files that do not have a valid owning user group

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/80/52/wKiom1c9v4SRYRYyAAA7XPQvPSU358.png "title=" Untitled. png "alt=" Wkiom1c9v4sryryyaaa7xpqvpsu358.png "/>

(6)-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 means that the file change time is now N days ago. The Find command also has the-atime and-ctime options, but they both and the-m time option.

Example: you want to look for files within the system's current directory that are less than 3rd of change time:

Find. -mtime-3-print

In order to find files that change time before 3rd in the root directory, you can use:

Find/-mtime +3-print

(7)-newer File1! File2 look for a file that changes time than the file File1 new but older than the file file2.

Example: Find files that have changed time than files test.c new but older than file public:

Find-newer test.c! -newer Public-print

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/80/52/wKiom1c9w1vD1liUAACfLXnQENM710.png "title=" Untitled. png "alt=" Wkiom1c9w1vd1liuaacflxnqenm710.png "/>

(8)-type Find a file of a certain type, such as: B-block device file. D-Directory. C-character device file. P-Pipeline file. L-Symbolic link file. F-Normal file.

Example: Find normal file (f) in the current directory, directory file (d), Symbol connection file (l)

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/80/50/wKioL1c9xoPhGm1DAABi--eCjMc905.png "title=" Untitled. png "alt=" Wkiol1c9xophgm1daabi--ecjmc905.png "/>

(9)-size N:[c] Find files with a file length of n blocks, with C indicating the length of the file in bytes. -depth: When looking for a file, first find the file in the current directory, and then look in its subdirectories.

Example: Looking for a file with a file length of 10 bytes in the current directory

Find. -size 10-print

The Find command starts with the current directory and looks for a file named Con.file.

Find. "CON." FILE "-depth-print

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/80/50/wKioL1c9yK2x26pjAAAiAn-QP_w607.png "title=" capture. PNG "alt=" Wkiol1c9yk2x26pjaaaian-qp_w607.png "/>

-mount: Do not cross the file system mount point when locating files

Example: Starting from the current directory find files in the file system with the file name ending in XC

Find. -name "*. XC "-mount-print

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/80/52/wKiom1c9yL_C0hzKAABM-xqA0eI834.png "title=" capture. PNG "alt=" Wkiom1c9yl_c0hzkaabm-xqa0ei834.png "/>

This article is from the "Shuoyuexinmao Cloud" blog, please be sure to keep this source http://19940325.blog.51cto.com/10789287/1775202

linux--Learning Chapter (ii) of the 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.