Basic usage 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: searches for files whose owner is xx.
-Group: Find the xx file of the group
-Uid useruid: Find the uid File
-Gid groupid: Find the file with the gid number
-Nouser: searches for files with no owner, that is, files exist but users have been deleted.
-Nogroup: Search for files without groups
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: file smaller than the file size
Search by Time
In units of 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 should be successful if one match exists. 600 indicates three objects, which are used on CentOS7 of the 6 owner./600
-Perm-600: each object must have the specified permissions at the same time. The three objects must be set up at the same time. For example,-003 indicates that other users must have the write and execution permissions.
Combination condition search
-A: corresponds
-O: or
-Not: non
! : Non
Processing action
-Print: print to the screen
-Ls: The searched file is ls
-Delete: delete the searched file.
-OK command {}\; execute the command specified by command on the searched file, interactive
-Exec command {}\; Same as above, non-interactive
{}: Indicates the name of the file found in the previous find operation.
For example:
Find./-type f-exec cp {}{}. bak \; copy all the searched files to a. bak file.
Action transmission mode after finding
Default: one-time transfer when a specified type of file is found
Xargs: 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:
Find the *. txt file under the/home/test directory
Find/home/test-name "*. txt"-print
The search permission is 755
Find/home/test-perm 755-print
Query if the owner is test
Find/home/test-user test-print
The search array is test's
Find/home/test-group test-print
Find
Find/home/test-mtime-5-print
Find
Find/home/test-mtime + 3-print
Find all directories
Find/home/test-type d-print
Find all files except Directories
Find/home/test! -Type d-print
Search for files
Find/home/test-type f-print
Search for symbolic link files
Find/home/test-type l-pint
Excluding test. sh in the/home/test/directory
Find/home/test-name "test. sh"-prune/home/test-print
Delete the test. sh File
Find/home/test-name "test. sh"-type f-exec rm {}\;
Show files starting with test
Find/home/test-name "* test *"-type f-exec more {}\;
Linux find command usage Summary
File SEARCH Command in Linux -- find
Find a file in Linux
Detailed description of the find command in Linux
Use of find, a text search tool
Powerful find command
Detailed description of the find command in Linux
This article permanently updates the link address: