Basic usage overview of the find command, and usage overview of the find command
Compared with the non-real-time SEARCH command like locate, the find command greatly increases the convenience and accuracy of our search; in addition, it can easily help us find and delete large files and specific types of files, especially when there are more than a few small broken files, it is extremely convenient .... search by owner Group
-User username: Find the file whose owner is xx-group: Find the xx file of the group-uid useruid: Find the file whose owner is uid-gid groupid: search for files with the gid number-nouser: Find files without a master, that is, files exist but the user has been deleted-nogroup: Find files without a group
Search by file type
-Type f: common file-type d: directory file-type l: Symbolic Link file-type s: Socket file-type B: block device file-type c: character device file-type p: MPS queue File
Search by size
-Size + 10 M: Files larger than 10 M-size + 10 k: Files larger than 10 k-size + 1G: files larger than 1G-size-1G: files smaller than the file size
Search by Time
One day-atime: Access time-mtime: modification time-ctime: change time in minutes:-amin: Access time
-Mmin: modification time
-Cmin: Change Time
Search by permission
-Perm + mode:-perm + 600: Other permissions of the owner group must be matched. 600 indicates three objects, use/600-perm-600 on CentOS7: each object must have the specified permissions at the same time. The three objects are also valid, for example: -003 indicates that other users must have the write and execution permissions.
Combination condition search
-A: And-o: or-not: not! : Non
Processing action
-Print: print to the screen-ls: Perform ls-delete on the searched file: delete the searched file-OK command {}\; execute the command specified by command on the file to be searched. Interactive-exec command {}\; is the same as above. non-interactive {}: indicates the name of the file found in the previous find, for example, find. /-type f-exec cp {}{}. bak \; copies all the searched files. bak FileAction transmission mode after findingDefault: one-time transfer when a specified type of file is foundXargs: The xargs command enables the transfer mode of the find search to find one and pass it to the action. It is easy to delete many broken files,Example: find-type f | xargs command;Related examples:
Search for the symbols in the/home/test directory *. txt file find/home/test-name "*. txt "-print: The search permission is 755. find/home/test-perm 755-print. The search owner is test's find/home/test-user test-print. The search array is test. find/home/test-group test-print find/home/test-mtime-5-print if the change time is less than 5 days find/home/test if the change time is greater than 3 days -mtime + 3-print: find/home/test-type d-print all files except directories find/home/test! -Type d-print: find/home/test-type f-print the symbolic link file. find/home/test-type l-pint does not include/home/test/ test. shfind/home/test-name "test. sh "-prune/home/test-print delete test. sh file find/home/test-name "test. sh "-type f-exec rm {}\; the file" find/home/test-name "* test *"-type f-exec more {}\ "starting with" test "is displayed {}\;