find - recursively processing files in the directory hierarchy

Overview SYNOPSIS

find [path...] [expression]

Description DESCRIPTION

This document is a version of GNU find manual command. find each file name of the directory tree search, which calculation given expression from left to right, in accordance with the priority rules (see section OPERATORS Operators) match, until the outcome (operation in the left 'and' operation results false, the obtained true 'or' operation), and then find moves to the next file name.

The first to '-', '(', ')', '' or the start of these parameters is the expression of the characters start; any arguments before it are paths to search, in which after the '!' any remainder of the parameters are expressions. If there is no path argument, with the current default directory. If there is no expression, with a default expression '-print'.

When all files are processed successfully find exits with status value 0. If an error occurs a value greater than 0 is returned.

Expressions EXPRESSIONS

Expression by option (option always affect all operations, and deal with more than just a file specified, and always return true), tests (test returns a true value or a false value), and action ( action has side effects, return a true or false value) components. They are separated by an operator. Ignored when the operator, -and default connection. If the expression contains no actions other than -prune, when the expression is true -print operation is executed.

Options OPTIONS

All options always return true, they will always be performed unless in the expression is unreachable place. Therefore, for clarity, it is best to put them in the beginning of the expression.

-daystart
From the beginning instead of 24 hours before, the computation time (for -amin, -atime, -cmin, -ctime, -mmin, and -mtime) day from the start.
-depth
Content first deal directory reprocessing directory itself.
-follow
Does not retrieve the symbolic link. Implied -noleaf.
-help, --help
Lists the find command line usage summary and exit.
-maxdepth levels
When the command line parameters into the lower directory specified by the directory, not more than the deepest Levels (a non-negative integer). `-maxdepth 0 'means that only perform tests and actions in the command line parameter specifies the directory.
-mindepth levels
Not Levels (a non-negative integer) perform any tests and actions within the layer. `-mindepth 1 'means process all files except the command line parameter to specify the file directory.
-mount
Do not enter in the directory above the other file systems. -Xdev can be used instead of so and some other versions of find compatible.
-noleaf
Not "subdirectory of the directory number of connections less than 2 hard" to do this assumption optimization. This option when searching for those file systems do not follow the conventions of the UNIX file system links with, such as loading point CD-ROM, MS-DOS file system or AFS volume. In conventional UNIX file system, each directory having at least two hard links, its name and its '.' Entry. Further, its subdirectories (if any) will have a '..' linked to it. In find retrieving a directory, a subdirectory number less than the number of connections it found two, it knows that the other entries in the directory is not a directory (the directory but leaves ( `leaf ') node in the tree). Unless this is required to retrieve the leaf node, otherwise no need to deal with it. This will bring great search faster.
-version, --version
Print find version number and exit.
@xd
Do not enter in the directory above the other file systems.

Testing TESTS

The numerical parameters can be thus given:

+n
Is the ratio of n large,
-n
Is the ratio n is small,
n
It happens to be the n- .
-amin n
Last Visit to the file in n before the minutes.
-anewer file
A visit to the file than the most recent file modification time is later. If the command line -follow comes before -anewer, (only in this case) -anewer will be affected by -follow impact.
-atime n
Last Visit to the file is n * Before 24 hours.
-cmin n
File's status was last changed in n before the minutes.
-cnewer file
File's status was last changed than the file modification time is later. If the command line -follow comes before -cnewer, (only in this case) -cnewer will be affected by -follow impact.
-ctime n
File's status was last changed in n * Before 24 hours.
-empty
File is empty regular file or empty directory.
-false
Always false.
-fstype type
File in type on the type of file system. Valid file system type is different in different versions of Unix; an incomplete list of file system types in a number of Unix is: ufs, 4.2, 4.3, nfs , tmp, mfs, S51K, S52K you can use -printf. plus% F directive to see the types of your file system.
-gid n
In the form of digital file group ID is n- .
-group gname
File belongs gname (also allows numeric group ID).
-ilname pattern
And -lname similar, but the match is not case-sensitive.
-iname pattern
And similar -name, but the match is not case-sensitive. For example, `fo * 'and` F ??' mode and a file name `Foo ',` FOO', `foo ',` fOo' etc. match.
-inum n
I files of nodes is n- .
-ipath pattern
And similar -path, but the match is not case-sensitive.
-iregex pattern
And -regex similar, but the match is not case-sensitive.
-links n
File has n links.
-lname pattern
It is a file with the pattern matching symbolic link. Metacharacters will not `/ 'or`.' Special treatment.
-mmin n
A recent modification to the file data is n before the minutes.
-mtime n
A recent modification to the file data is n * Before 24 hours.
-name pattern
Basic file name (path leading directories removed) and the shell pattern pattern match. Metacharacters ( `* ',`?', And `[] ') does not match the beginning of the file name'. '. Use -prune to skip a directory and the files. See examples described in -path.
-newer file
The file was last changed than the file modification time is later. If the command line -follow comes before -newer, (only in this case) -newer will be affected by -follow impact.
-nouser
The user does not conform to file's numeric user ID.
-nogroup
Group ID of the group did not meet in digital form file.
-path pattern
Filename pattern with shell pattern match. Metacharacters will not `/ 'or`.' Special treatment. Thus, for example:
. Find -path './sr*sc'
if there './src/misc', then it will be printed out. To ignore a complete directory tree, -prune should be used instead of checking all the files in the directory tree. For example: To skip 'src / emacs' directory and all subdirectories and files, print files to find the other, this should:
. The Find -path './src/emacs' -prune -o -print
-perm mode
File permission bits are exactly the MODE (octal or symbolic). Symbolic modes use mode 0 as a point of departure.
-perm - mode
All of the permission bits mode are set up file.
-perm + mode
Any permission bits mode are set up file.
-regex pattern
Filename regular expression pattern matching. This is a match for the whole path, not a search for files. For example, to match the name `./fubar3 'files, can use regular expression`. * Bar.' Or `. * B. * 3 ' , but not with` b. * R3'.
-size n[bckw]
File uses n units of memory cells. The default units are blocks of 512 bytes, may also be used n followed by `b 'value is specified. Other units of bytes, if n plus behind `c '; kilobytes (kB), if n plus behind` k'; two-byte word, if n plus behind `w '. Size is not included in the indirect blocks, but did not block the loose accounting documents in real space allocation.
-true
Always true.
-type c
File is c type. Types values are as follows:
b
Special block file (buffered)
c
Special characters in file (no buffering)
d
table of Contents
p
Named pipe (FIFO)
f
Trivial File
l
Symbolic link
s
Sockets
D
Door (Solaris-specific)
-uid n
In the form of digital files of user ID is an n- .
-used n
The last file accessed in the last modify its state n days after.
-user uname
Owner of the file is uname (can also be used in digital form user ID).
-xtype c
And the same as -type unless the file is a symbolic link. For symbolic links: -follow If not given, if the file is a point c link to the file type, then the return true; -follow if given, if c is `l 'then returns true. In other words, for symbolic links, -xtype check the file that -type does not check.

Action ACTIONS

-exec command ;
Performing Command ; If the command returns the 0 state, the exec returns true. All find the remaining command line arguments as a parameter to the command, until it encounters one of `; 'up parameters thereof. Command parameters, the string '{}' will replace the file name being processed. All '{}' will be replaced, not only in a single parameter. Some versions of find not do so. These parameters may need `\ 'to escape or enclosed in parentheses, they are deployed to prevent the shell. Command is executed from the home directory.
-fls file
Return true; -ls but write as similar as -fprint File .
-fprint file
Return true; the full name of the file to print to a file file in. If you run the find when file does not exist, it is created. If it exists, it will be overwritten. File name `` / dev / stdout '' and `` / dev / stderr '' will be given special treatment; respectively refer to the standard output and standard error.
-fprint0 file
Return true; but written as similar -print0 like -fprint File .
-fprintf file format
Return true; but written as similar -printf like -fprint File .
-ok command ;
Similarly -exec but will first ask the user (the standard input); if not responded to `y 'or` Y' does not start operation command but returns false.
-print
Return true; the standard output print the full file name, followed by a newline.
-print0
Return true; the standard output print the full file name, followed by a null character. Such processing may cause the find program output can be properly understood by the file name with a line break.
-printf format
Returns true; standard output print the format , explained `\" Escape there `% 'commands. And field width accuracy can function as C `printf 'as specified. The difference is that the -print, -printf end of the string does not add a new row. Escape and instructions are available:
\a
Warning bell
\b
go back
\c
Immediately stop the current output format, refresh the output device.
\f
End of table
\n
New row
\r
Enter
\t
Horizontal tab
\ v
Vertical tab
\\
Output itself `\ '
\NNN
ASCII code is NNN (octal) character

In a `\ 'followed by any other character as an ordinary character is a character, so they will be printed.

%%
Output itself `% '
%a
The last time file access time. Format is C `ctime 'function return value format.
%A k
The last time file access time. Format k specified, may be `@ 'or` the strftime function C' instruction format. The following lists the k value is available; some may not be available on all systems, since different systems `strftime 'are different.
@
The number of seconds from Jan. 1, 1970, 00:00 GMT plays

Time fields:

H
Hour (00..23)
I
Hour (01..12)
k
Hour (0..23)
l
Hour (1..12)
M
Minute (00..59)
p
Local AM or PM
r
12-hour format time (hh: mm: ss [AP] M)
S
Seconds (00..61)
T
Time 24-hour format (hh: mm: ss)
X
Local time representation (H: M: S)
WITH
Time zone (eg, EDT), can not decide if the area is empty

Date Field:

a
Local week abbreviation (Sun..Sat) the name of the day
A
Local week full name, variable length (Sunday..Saturday) per day
b
Local Monthly abbreviation of the name (Jan..Dec)
B
Local Monthly full name, variable length (January..December)
c
Local date and time representation (Sat Nov 04 12:02:33 EST 1989)
d
Among the day of month (01..31)
D
Date (mm / dd / yy)
h
And b are the same
j
Day of the year (001..366)
m
Month (01..12)
The
Starting with Sunday as a weekly, year of week (00 .. 53)
w
One week among the day (0..6)
W
Starting with Monday as a weekly, year of week (00 .. 53)
x
Local date representation (mm / dd / yy)
Y
The last two years (00..99)
Y
Year (1970 ...)
%b
File size, in units of 512-byte blocks (rounded).
%c
File status last modification time. Format is C `ctime 'function return value format.
%C k
File status last modification time. Format k specified, similar% A.
%d
File depth in the directory tree; 0 means the file is a command line parameter.
%f
Remove the file name in front of the directory (only the last component).
%F
Where the file system type of the file; this value may be used as -fstype.
%g
The group name of the file, if the group has no name or numeric group ID.
%G
Digital form file group ID.
%h
In front of the directory part of the file name (removal of only the last ingredient).
%H
According to locate the file command line parameters.
%i
i node number (hexadecimal) file.
%k
File size, in units of blocks 1kB (rounded).
%l
Symbolic link target (if the file is not a symbolic link, then the result is an empty string).
%m
Permission bits (octal) file.
%n
Hard links files.
%p
file name.
%P
File name, removing the name, according to the command file section to find the line parameters.
%s
File size, in bytes.
%t
The last time the file was modified. Format is C `ctime 'function return value format.
%T k
The last time the file was modified. Format k specified, similar% A.
in%
User name of the file, if the user has no name or numeric user ID.
% U
Digital form file user ID.

In a `% 'character behind the use of any other characters,`%' is ignored (but the other character is printed).

-prune
If no -depth return true; do not enter the current directory.
If given -depth false returns; no effect.
-Ls
Returns true; to `ls -dils' standard output file formats listed. Block count bytes to 1kB unless the POSIXLY_CORRECT the environment variable, in that case use 512 byte blocks.

OPERATORS Operators

They are arranged in descending order of priorities:

( expr )
Forced priority
! expr
If expr is false if true
-not expr
And! Expr same
expr1 expr2
And (implicit default operator); if expr1 is false is not performed expr2
expr1 -a expr2
And expr1 expr2 same
expr1 -and expr2
And expr1 expr2 same
expr1 -o expr2
Or; if expr1 is true is not performed expr2
expr1 -or expr2
And expr1 -o expr2 same
expr1 , expr2
List; expr1 and expr2 will be executed. expr1 value is ignored, the list of values is expr2 value  

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11082326.html
Recommended