The Linux Find command searches the directory structure for files and performs the specified actions.
The Linux Find command provides quite a lot of look-up conditions and is powerful, so there are many options, many of which are worth our deep understanding of learning.
command format: Find Pathname-options [-print-exec-ok ...]
Command function: Used to find files in the file tree and make corresponding processing (possibly Access disk)
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: 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 each command is executed.
Below is the function details of the Find command option:
1.-name search files by file name
The file name option is the most common option for the Find command, which can be used alone or with other options. You can use a file name pattern to match files, and note that you enclose the filename pattern in quotation marks. No matter what the current path is, available ~ as the ' pathname ' parameter, the tilde ~ represents your $home directory.
For example:
To find all the ' *.log ' files in the current directory and subdirectories, you can:
650) this.width=650; "title=" 1.png "src=" Http://s3.51cto.com/wyfs02/M02/80/5A/wKioL1c-oLKzJANdAAAamknj3uw614.png " alt= "Wkiol1c-olkzjandaaaamknj3uw614.png"/>
You want the current directory and subdirectories to find file names that begin with an uppercase letter, available:
650) this.width=650; "title=" 2.png "src=" Http://s1.51cto.com/wyfs02/M02/80/5A/wKioL1c-oM-Rv0RKAAAx5IDUV68820.png " alt= "Wkiol1c-om-rv0rkaaax5iduv68820.png"/>
To find files with file names beginning with host in the/etc directory, you can:
650) this.width=650; "title=" 3.png "src=" Http://s5.51cto.com/wyfs02/M00/80/5C/wKiom1c-oA_CU_ufAAAc7e3AG7I299.png " alt= "Wkiom1c-oa_cu_ufaaac7e3ag7i299.png"/>
To find files in the $home directory, you can:
650) this.width=650; "title=" 4.png "src=" Http://s4.51cto.com/wyfs02/M00/80/5C/wKiom1c-oCSz8GH0AAAse-nVbU4028.png " alt= "Wkiom1c-ocsz8gh0aaase-nvbu4028.png"/>
2,-perm follow the file permissions to find files
To find files by file permission mode. It is best to use the octal permission notation.
Find files with file permission bit 644 in the current directory, available:
650) this.width=650; "title=" 5.png "src=" Http://s2.51cto.com/wyfs02/M01/80/5A/wKioL1c-oSnjF-b0AABVQHQ6ygk116.png " alt= "Wkiol1c-osnjf-b0aabvqhq6ygk116.png"/>
3.-prune Ignore a directory
Use the-prune option to indicate which directories need to be ignored. If the-depth option is used at the same time, then the-prune option is ignored by the Find command.
Locate the file under the File1 directory, but do not want to find it in the File1/file3 directory, you can use:
650) this.width=650; "title=" 6.png "src=" Http://s2.51cto.com/wyfs02/M00/80/5A/wKioL1c-phjgXHvDAAAZMP0igBw206.png " alt= "Wkiol1c-phjgxhvdaaazmp0igbw206.png"/>
4,-user According to file owner to find files
-nouser finding files without a valid owner
Find files in the $home directory where the file belongs to the master yangning
650) this.width=650; "title=" 7.png "src=" Http://s4.51cto.com/wyfs02/M00/80/5A/wKioL1c-pyKiytZTAAA0vg66TSQ085.png " alt= "Wkiol1c-pykiytztaaa0vg66tsq085.png"/>
In order to find files that do not exist for the master account, you can use the-nouser option.
Find all of these files in the/home directory
such as: Find/home-nouser-print
5.-group to find files according to the group to which the files belong
-nogroup Find files for five valid owning groups
Just like the user option, for the group of users to which the file belongs.
To find files belonging to the Gem User group under the/apps directory, you can use:
Find/apps-group Gem-print
To find all files that do not have a valid group of users, you can use the Nogroup option.
To find such a file from the root of the file system, you can:
Find/-nogroup-print
6.-type find a file of a certain type
B--Block device files
D--Catalogue
C--Character device file
P--Pipeline file
L--Symbolic link file
F--Normal file
Find all directories in the current directory
650) this.width=650; "title=" 8.png "src=" Http://s5.51cto.com/wyfs02/M02/80/5D/wKiom1c-p7mTtw-RAAAeXo-d5Ak863.png " alt= "Wkiom1c-p7mttw-raaaexo-d5ak863.png"/>
Find all the symbolic link files in the/etc directory
650) this.width=650; "title=" 9.png "src=" Http://s4.51cto.com/wyfs02/M00/80/5B/wKioL1c-qXWxbHn6AAAvfKY_-F8111.png " alt= "Wkiol1c-qxwxbhn6aaavfky_-f8111.png"/>
7,-size N: [c] Find file length n block file, with C file length in bytes
Find files with files longer than 1000 bytes in the current directory, which are available:
650) this.width=650; "title=" 10.png "src=" http://s2.51cto.com/wyfs02/M01/80/5B/wKioL1c-qg7jw714AAArdpAFmPA081.png "alt=" Wkiol1c-qg7jw714aaardpafmpa081.png "/>
Find files that are longer than 10 blocks in the current directory (a chunk equals 512 bytes)
650) this.width=650; "title=" 11.png "src=" http://s3.51cto.com/wyfs02/M00/80/5B/wKioL1c-qk_CTsB0AAA7oBr6vNk423.png "alt=" Wkiol1c-qk_ctsb0aaa7obr6vnk423.png "/>
8,-depth find the file, first find the file in the current directory, and then find in its subdirectories
Starting at the root of the file system, look for a file named Con.file.
650) this.width=650; "title=" 12.png "src=" http://s2.51cto.com/wyfs02/M00/80/5D/wKiom1c-qcbQI0ayAAAj7UcPHjE160.png "alt=" Wkiom1c-qcbqi0ayaaaj7ucphje160.png "/>
It will first match all the files and then go to the subdirectory to find
9,-newer File1! File2 find change time than file1 new but older than file2 file
Find a file that has changed more time than file, but file1 older than file
650) this.width=650; "title=" 13.png "src=" http://s5.51cto.com/wyfs02/M00/80/5B/wKioL1c-q0-Db4SlAAAdI_yW5aE413.png "alt=" Wkiol1c-q0-db4slaaadi_yw5ae413.png "/>
10.-mtime-n +n Find files by change time
-atime-n +n Find files by access time
-ctime-n +n Find files by changing time
Use a minus sign-to limit the time to change the file within the current n days, and use the Plus + to limit the change time before the current n days of the file.
To find files that change within 10th of the system root directory, you can use:
650) this.width=650; "title=" 14.png "src=" http://s2.51cto.com/wyfs02/M02/80/5B/wKioL1c-q_Pwjo2sAAAn77gHRx8354.png "alt=" Wkiol1c-q_pwjo2saaan77ghrx8354.png "/>
The above is my find command some of the options of learning summary, inevitably have omissions, forgive me!!!!
Linux Find command details