Find manual

xiaoxiao2021-03-06  43

Find

Find

Section: Misc. Reference Manual Pages (1L "- * - NROFF - * -)

Name

Find - Recursively handles files in the hierarchy directory

Total stemsis

Find [PATH ...] [EXPRESSION]

Description Description

This document is the manual of the GNU version of the Find command. Find Search Each file name on the directory tree, it is calculated from left to right, according to priority rules (see

The operator Operators section is matched until the result is obtained (the left calculation is fake in 'and' operation, "is true in 'or' operation), then Find moves down one

file name.

The first parameter started with '-', ',') ',', 'or'! 'Is the beginning of the expression; any parameter before it is the path to search, after it of

Any parameter is the remainder of the expression. If there is no path parameter, the current directory is default. If there is no expression, the default expression is used with '-Print'.

When all files are successfully processed, the FIND exits and returns the status value 0. If an error occurs, a value greater than 0 is returned.

Expression Expressions

Expressions are option (options always affect all operations, not just a specified file processing, but always return true value), test (test returns a true value or one

The fake value), there is also actions (the action is Side Effects, returns a truth or false value). They are separated by an operator. When ignoring the operator, the -and connection is used by default.

If the expression does not contain -Prune, the -Print action is performed when the expression is true.

Option options

All options always return true values, and they will always be performed unless they are not implemented in the expression. Therefore, it is clear that it is best to put them in the beginning of the expression.

section.

-daystart

Starting from the start of the day instead of 24 hours before, calculation time (for -amin, -atime, -cmin, -ctime, -mmin, and -mtime).

-Depth

Process the contents of the directory you first processed itself.

-FOLLOW

Do not retrieve the symbolic link. Implicit-Noleaf.

-help, --help

List the summary of the command line method of the Find, then exit.

-maxdepth level

When entering the directory of the command line parameters, the LEVELS (a non-negative integer) layer is not exceeded. `-maxdepth 0 'means only in the directory specified in command line parameters

Perform test and action.

-Mindepth Levels

No testing and action is performed within Levels (a non-negative integer) layer. `-mindepth 1 'means processing all files, in addition to files in the directory specified by the command line parameter

.

-mount

Do not enter the directory that is above other file systems. You can use -XDEV instead to compatibility with some other versions of Find.

-Noleaf

Optimization of this assumption that is not "the number of catalogs in the directory is 2". This option is in searching for those file systems that do not follow UNIX file system links, such as

CD-ROM, MS-DOS file system, or loading point of AFS volume. In a normal UNIX file system, each directory has at least two hard connectivity, its name and its '.' Entry. In addition

Its sub-directory (if any) will have one '..' link to it. When finding a directory in Find, the number of subdirectors is found to be less than its number of connections, it knows the directory.

Other entries are not a directory (but the leaves in the directory tree (`Leaf ') node). Unless you need to retrieve this leaf node, there is no need to deal with it. This can bring a lot of search speed enhancement.

-Version, --Version

Print the version number of the Find and then exit.

-xdev

Do not enter the directory that is above other file systems.

Test Tests

Number parameters can be given this:

N

It is better than N,

NN

It is smaller than N,

n

It is just n.

-amin n

The most recent visit to the file is before N minutes.

-anewer file

The most recent visit to the file is better than the file modification time. If the command line is -Follow before -newer, (only in this case) -anewer will be affected

The effect of -follow.

-time n

The most recent visit to the file is before N * 24 hours.

-cmin n

The last revision of the file status is before N minutes.

-cnewer file

The most recent revision of the file status is better than the file modification time. If the command line is -folow before -cnewer (only in this case) -cnewer will be affected

The effect of -follow.

-ctime n

The most recent revision of the file status is before N * 24 hours.

-empty

The file is empty ordinary file or empty directory.

-false

Always False.

-fstype type

The file is above the file system of Type type. Effective file system types are different in different versions of UNIX; some incomplete file system types in UNIX

This: UFS, 4.2, 4.3, NFS, TMP, MFS, S51K, S52K. You can use -printf to add% F instruction to view your file system.

-gid N

The group ID of the digital form of the file is n.

-group gname

The file belongs to GNAME (also allowed to use a group ID).

-ilname pattern

Similar to -lname, but when matching is case-sensitive.

-IName Pattern

Similar to -Name, but when matching is case-sensitive. For example, `fo * 'and` f ??' mode matches file name `foo ',` foo', `foo ',` foo', etc.

-inum n

The number of I nodes of the file is n.

-ipath pattern

Similar to -path, but matching is not case sensitive.

-iRegex Pattern

Similar to -Regex, but when matching is case-sensitive.

-LINKS N

The file has n links.

-lname pattern

The file is a symbolic link that matches Pattern. The metadature does not do special treatment for `/ 'or`' '.

-mmin n

The most recent revision of the file data is before N minutes.

-mtime n

The most recent revision of the file data is before N * 24 hours.

-Name Pattern

The basic file name (the path to the previous directory) matches the shell mode Pattern. Metacity (`* ',`?', And `[] ') does not match the file name starting.'.

Use -prune to skip a directory and files. View the example of the -path.

-newer file

The most recent revision of the file is late than the file modified time. If the command line is -Follow before -newer (only in this case) -newer will be affected

The effect of -follow.

-nouser

Users who do not match the digital form of the file user ID.

-NOGROUP

Group IDs in the digital form of the file do not match the file.

-Path Pattern

The file name matches the shell mode Pattern. The metadature does not do special treatment for `/ 'or`' '. Therefore, for example: find. -Path './sr*sc'

If there is './src/misc', print it out. To ignore a complete directory tree, you should use -Prune instead of checking all the files in the directory tree. example

For example: To skip the 'src / emacs' directory and all of the files and subdirectories, print out the files found, should be:

Find. -path './src/emacs' -prune -o -print

-Perm Mode

The authority bit of the file is just Mode (octal or symbol). Symbolic Modes Use Mode 0 as a point of departure.

-Perm -Mode

All permission bit modes are set up files.

-Perm Mode

Any power limit Mode is set.

-Regex Pattern

The file name matches the regular expression Pattern. This is a matching of the entire path, not searching files. For example, to match files named `.fubar3 ', you can use regularly

Expression `* bar. 'Or`. * B. * 3', but can't use `b. * R3 '.

-size n [bckw]

The file uses N unit storage unit. The default unit is a 512-byte block, or it can be used to add `b 'to specify this value. Other units are bytes, if in N

Adding a `C '; kilobyte (KB), if you add` k' after n; two bytes of words, if you add `W 'after n. The size is not allowed to enter Indirect Blocks, but

It is a block that will be placed in loose files that do not really allocate space.

-True

Always True.

-type c

The file is Class C. The type can be obtained as follows:

B

Special block file (buffer)

c

Special character file (without buffering)

di

table of Contents

p

Named pipe (FIFO)

fly

Ordinary document

l

Symbolic link

s

Socket

Di

Solaris unique

-UID N

The user ID of the digital form of the file is n.

-USED N

The last time of the file is after the last modified N days of its state.

-user uname

The owner of the file is Uname (you can also use the user ID in the digital form).

-XTYPE C

Same as -type, unless the file is a symbolic link. For symbolic links: If you don't give -folow, if the file is a link to the C type file, then

Returns True; if -Follow is given, if C is `l ', then returns True. In other words, for symbolic links, -Xtype checks those-TPEs that do not check.

.

Action ActionS

-EXEC Command;

Execute Command; if the command returns the status value 0, then EXEC returns True. All Find the rest of the command line parameters will be used as a parameter provided to the command until an encounter

The parameter consisting of `';'. In the parameter of the command, the string `{} 'will replace with the file name being processed. All `{} 'will be replaced, not only in a separate

Parameters. Some versions of Find are not doing this. These parameters may need to be enclosed with `/ 'to hose with parentheses to prevent them from being launched by the shell. The command is executed from the start directory.

-fls file

Returns true; similar to -ls but writes File as -fprint.

-fprint file

Return true; print the full name to the file file. If File does not exist if you run Find, it will be created. It will be overwritten if it exists. file name

`` / dev / stdout '' and `` / dev / stderr '' will be dealt with; they refer to standard output and standard error output, respectively.

-fprint0 file

Returns True; Similar to -Print0 but writes File as -fprint.

-fprintf File Format

Returns True; Similar to -Printf but writes File as -fprint.

-ok command;

Similar to -EXEC, you will ask the user (in standard input); if the response is not to `Y 'or` y' starting, it will not run Command but return false.

-print

Returns true; in the standard output print file full name, then a newline.

-print0

Returns true; in the standard output print file full name, then a null character. This makes it possible to process the output of the Find to correctly understand the text with a wrap.

File name.

-Printf Format

Returns true; in the standard output printing Format, explain the `/ 'escape and`%' instructions. Field width and accuracy can be specified as the C function `Printf '. versus

-print is that -Printf does not add a new line at the end of the string. The available ESCAPE and instructions are as follows:

/ a

Warning ringtones

/ B

go back

/ c

Stop immediately, output, refresh the output device.

/ f

Table end

/ N

New line

/ r

Bus stop

/ t

Horizontal Tab

/ v

Vertical Tab

//

Output itself `/ '

/ NNN

ASCII encoding is a nnn (octal) character

Using any other characters after a `/ 'character will be used as a normal character, so they are printed.

%%

Output itself `% '

% a

The last time the file is last accessed. The format is the format of the C function `ctime 'return value.

% AK

The last time the file is last accessed. The format is specified in k, can be `@ 'or the C function` strftime' instruction format. The following is listed below; there are some

Not available on all systems, because `strftime 'in different systems is different.

@

From Jan. 1, 1970, 00:00 GMT

Time field:

Hide

Hours (00..23)

I

Hours (01..12)

k

Hours (0..23)

l

Hours (1..12)

M

Minute (00..59)

p

Local AM or PM

r

12 hours format time (hh: mm: ss [AP] M)

S

Second (00..6)

T

Time in 24 hours (hh: mm: ss)

X

Localization time representation (h: m: s)

Z

Time zone (for example, EDT), if the time zone cannot be determined is empty

Date field:

a

Abbreviation for daily names in the local week

A

Local name, variable length (Sunday..SATURDAY)

B

Local monthly name of the abbreviation (JAN..DEC) B

Local name, variable length (January..December)

c

Local date and time representation (SAT NOV 04 12:02:33 EST 1989)

di

Days of a month (01..31)

Di

Date (mm / dd / yy)

hide

Same as B

j

Days in the year (001..366)

M

Month (01..12)

U

As a week from Sunday, the week (@53)

w

Days in a week (0..6)

W

Taking Monday as a week start, the week (@53)

x

Local date representation (mm / dd / yy)

y

The last two (@99)

Y

Year (1970 ...)

% B

The file size, units in 512 bytes (rounded).

% C

The last modified time of the file status. The format is the format of the C function `ctime 'return value.

% CK

The last modified time of the file status. The format is specified in K, similar to% a.

% D

The depth of the file in the directory tree; 0 means that the file is a command line argument.

% f

Remove the file name of the previous directory (only the last ingredient left).

% F

The type of file system where the file is located; this value can be used for -fstype.

% g

The group name of the file, if the group is not named, the group ID of the digital form.

% G

Group ID of the digital form of the file.

% h

The previous directory section of the file name (remove the final ingredient only).

% H

According to the command line parameters of the file.

% i

The i junction number (16) of the file.

% K

The file size, units in 1kb (rounded).

% L

The target of the symbolic link (if the file is not a symbolic link, then the result is an empty string).

% M

The permission bit of the file (8).

% N

The hard connection number of files.

% P

file name.

% P

The file name removes the name part of the command line parameters of the file.

% s

The file size is in bytes.

% T

The last modified time of the file. The format is the format of the C function `ctime 'return value.

% TK

The last modified time of the file. The format is specified in K, similar to% a.

% U

The username of the file, if the user has no name, the user ID in the digital form.

% U

Digital form of files in the file.

Use any other characters after a `% 'character,`%' will be ignored (but other characters will be printed).

-prune

Returns true if -Depth is given; do not enter the current directory.

If -Depth is given, it returns false; there is no effect.

-LS

Returns true; in `ls -dils' format lists files in standard output. The block counts in units of 1kb bytes unless the environment variable posixly_correct, that is

Use 512 bytes of blocks.

Operator Operators

Arrange in high and low priority:

(EXPR)

Mandatory is priority

! Expr

Returns true if expr is false

-Not EXPR

Same as! EXPR

EXPR1 EXPR2

With (implied default operator); if EXPR1 is false, it will not perform EXPR2

EXPR1 -A EXPR2

The same as EXPR1 EXPR2

EXPR1 -AND EXPR2

The same as EXPR1 EXPR2

EXPR1 -O EXPR2

Or; if the expr1 is true, expr2 is not performed

EXPR1 -OR EXPR2

The same as EXPR1 -O EXPR2

EXPR1, EXPR2

List; EXPR1 and EXPR2 will be executed. The value of EXPR1 is ignored, the value of the list is the value of EXPR2

See See Alsolocate (1L), LocatedB (5L), UpdatedB (1L), Xargs (1L) Finding Files (INFO online help, or print version)

[Chinese version of the maintenance person]

Yuan Yi

[Chinese version latest update]

11/01/2003

"China Linux Forum MAN Handbook Translation Plan":

http://cmpp.linuxforum.net

转载请注明原文地址:https://www.9cbs.com/read-67005.html

New Post(0)