Linux find command Detailed

find command is used to locate the matching files in a given directory
find command Format: find pathname -options [-print -exec]
pathname indicates the path of a file or directory to find the find command. For example: / Home /
-print: find command output file matching to the standard output.
-exec: find command to execute shell commands given by the parameter file match. Form of these commands to 'command' {};, attention} and {\; space between.

-name
find files by file name.
-perm
by file permissions to locate the file.
-prune use this option to make the find command to find the specified not in the current directory, if you use the -depth option, -prune find command will be ignored.
-user
according to the file owner to locate the file.
-group
according to the group the file belongs to locate the file. 0
-nogroup
find no valid file owning group, i.e. belongs to the group of the file does not exist in the / etc / groups in.
-nouser
find no valid owner of the file, i.e., the owner of the file does not exist in the / etc / passwd in.
-newer file1! file2
look for changes over time, but the new file file1 file2 older than the file file.
-type
find a certain type of file, such as:
B - block device file.
d - directory.
c - a character device file.
p - pipe file.
l - a symbolic link file.
f - regular file.
-size n: [c] lookup file block length n files, file length in bytes indicates time with c.
-depth: When searching file, first locate the file in the current directory, and then look at its subdirectories.
-maxdepth: find the directory maximum depth
-mindepth: Find minimum depth directory
-fstype: Find files located in a certain type of file system, the file system type can usually be found in the configuration file / etc / fstab, the configuration file contains information about the file system of the present system.
-mount: do not cross file system mount point when searching for files.
-follow: If you find command encounters a symbolic link file, trace the link points to a file.
-cpio: Use cpio command files that match will back up these files to tape devices.
-mtime -n + n # by file to change the time to find the file, -n refers to within n days, + n n refers days ago
-atime -n + n # by file access times to find

-ctime -n + n # by file creation time to find the file, -n refers to within n days, + n n refers days ago
eg:. find -group root -exec ls -l {}; View system is a root of all groups document

eg: find / -type f -size 0 -exec ls -l {}; See common file system for all the length of 0 and list the path

eg:. find -type f -perm 644 -exec ls -l {}; let the current directory the file owner has read and write permissions, and user and group file belongs to another user has read access to the file

eg: find / home -mtime 3 -type f | xargs du -sh find / home directory, the last three days modified files, and displays the file size

eg: find / var -type p -o -type l -mindepth 3 -a -maxdepth 3 Find / var directory, pl types of files at a third level directory

Published 61 original articles · won praise 11 · views 20000 +

Guess you like

Origin blog.csdn.net/wq962464/article/details/86586747