1. Find
Find [path]-Option [-print] [-Exec-OK command] {}\;
Search for files in a directory hierarchy
①-Print: outputs the searched file to the standard output, one file row
②-DeleteDelete the specified file
③-Exec command {}\; execute the command operation on the retrieved file. There is a space between {} And \;. "\;" is a fixed Terminator; {} will be replaced by the file
④-OK is the same as-exec, but you need to consult the user before the operation
2. Option
①-Type B/D/C/P/L/F # Check Block devices/directories/character devices/pipelines/symbolic links/common files
②-Perm # search by execution permission
③-Depth # search for the local directory before entering the subdirectory
④-Follow # If a symbolic link file is encountered, the file indicated by the link will be tracked.
Instance:
①$ Find.-type D-Print print the directory structure
②$ Find .! -Type D-print: Print non-directory files
③Find/usr/include-name '*. H'-exec grep af_inef6 {}\; (because grep cannot Recursively search subdirectories, it can be used with find. Find the af_inef6 string in the. h file in all/usr/include subdirectories)
④$ Find/etc-name "passwd *"-exec grep "cnscn" {}\; check whether a cnscn user exists
⑤$ Find.-Name "Yao *" | xargs file display file type
⑥$ Find-name AP *-o-name may * search for files starting with AP or may
7.$ Find/home-mtime-2 check files modified in the last two days under/home
Bytes$ Find/home-mtime + 2 check files modified last two days in/home
Bytes$ Find/home-mmin + 60 check files modified 60 minutes ago under/home
Bytes$ Find/home-Amin + 30 check the files that have been accessed in the last 30 minutes
11$ Find/home-mmin + 60 check files modified 60 minutes ago under/home
12$ Find/home-Amin + 30 check the files that have been accessed in the last 30 minutes
13$ Find/home-UID + 501 list files or directories with UID greater than 501 under/home
14$ Find/home-nouser: list files or directories that do not belong to local users in/home.
15$ Find/home-nogroup list files or directories in/home that do not belong to the Local Group
16$ Find/hom-name t.txt-maxdepth 4 list/homeinner tmp.txt depth up to three layers
17$ Find/home-name tmp.txt-mindepth 3 check from Layer 1
18$ Find/home-empty
19Find/tmp/-ctime + 7-delete files created one week ago in the/tmp directory
20Find./-Perm 755-print
3. Example
1) basic usage
Find/-name file name
Size-related:
-Size N [bkmg] the size is n (B is bit, C: byte, K: kb, M: MB, G: GB)
Find/-size 1500c (search for 1,500-byte files; c Indicates bytes)
Find/-size + 1500c (find files larger than 1,500 bytes, + indicates files larger)
Find/-size-1500c (find files smaller than 1,500 bytes,-Indicates smaller)
Time-related:
Find/-Amin n last n minutes
Find/-atime n last n days
Find/-Cmin n last n minutes change status
Find/-ctime n changes the status in the last n days
Find/-newer file requires a new file than the file.
2) advanced usage 1
Find/-empty blank file, blank folder, folder without subdirectories
Find/-false find files that are always wrong in the system
Find/-fstype type: Find the file that exists in the specified file system. For example, if the type is ext2
Find/-gid N group ID n files
Find/-group gname group file named gname
Find/-depth n preferentially searches for file content in a specified directory at a Layer
Find/-maxdepth levels search in a hierarchical directory in descending Mode
3) Advanced Search 2
-And and-or conditions or
4) Others
-The user name owner name is the name of the file.
-The group name owner user group name is a name file.
Reference
[1] The summary is good.
Http://techbbs.zol.com.cn/1/85_883.html
Http://bbs.linuxtone.org/thread-1425-1-1.html
Http://www.flatws.cn/article/program/shell/2011-06-13/30184.html
[2] More About find
Http://bbs.linuxtone.org/thread-1696-1-1.html
Http://linux.die.net/man/1/find
[3] Be optimistic
Http://www.linuxsir.org/main/node/137? Q = node/137 #1.1