linux命令之(5) find命令

1. NAME

find - search for files in a directory hierarchy

在目录结构中搜索文件。

2.SYNOPSIS

 find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression]
	   链接处理方式                                起始目录          限制条件

3. DESCRIPTION

This manual page documents the GNU version of find. GNU find searches the directory tree rooted at each given starting-point by evaluating the given expression from left to right, according to the rules of precedence (see section OPERATORS), until the outcome is known (the left hand side is false for and operations, true for or), at which point find moves on to the next file name. If no starting-point is specified, `.’ is assumed.

本手册页记录了GNU版本的find命令。GNU版本的find命令 根据给出的优先级规则,搜索从给定起点开始的目录树,直到知道结果。(对于与操作,左手边为假则假。对于或操作,左手边为真则为真。) ,查找到结果后查找下一个文件名。如果没有指定起点,默认为当前目录。

If you are using find in an environment where security is important (for example if you are using it to search directories that are writable by other users), you should read the `Security Considerations’ chapter of the findutils documentation, which is called Finding Files and comes with findutils. That document also includes a lot more detail and discussion than this manual page, so you may find it a more useful source of information.

如果你要在一个安全性很重要的环境中使用find命令(例如:你使用它取搜索其它用户的可写的目录),你应该读“安全注意事项”章节,这个章节被称为“文件查找”,并且附带了findutils。那个文档比当前文档包含了更多的细节和讨论。因此你可能发现一些更有用的信息来源。

The -H, -L and -P options control the treatment of symbolic links. Command-line arguments following these are taken to be names of files or directories to be examined, up to the first argument that begins with - , or the argument ( or `!’. That argument and any following arguments are taken to be the expression describing what is to be searched for. If no paths are given, the current directory is used. If no expression is given, the expression -print is used (but you should probably consider using -print0 instead, anyway).

-H -L -P 控制符号链接的处理。紧跟着这些参数的命令行参数 被用作查找文件或目录的名字(查找的目录),直到 第一个以- 开头的参数,或者 参数为 ( 或者!(查找规则)。那个参数(以- 开头的参数)以及紧跟着那个参数的其它参数被当做 搜索 目标 的 表达式。 如果没有给出路径,那就使用当前路径。如果没有给出表达式,那就使用 -print 作为表达式。(但是无论如何应该考虑用 -print0 代替。)

4. OPTIONS

-H
-L
-P
用来指定对于符号链接的处理
-D
-OLevel

5.EXPRESSION( 表达式)

The part of the command line after the list of starting points is the expression. This is a kind of query specification describing how we match files and what we do with the files that were matched. An expression is composed of a sequence of things:

命令行中 起始目录之后的部分是表达式。这是一种查询规范,描述我们如何匹配文件,以及我们对匹配的文做什么。表达式由一系列事情组成:

Tests

Tests return a true or false value, usually on the basis of some property of a file we are considering. The -empty test for example is true only when the current file is empty.

Tests 根据我们所关注的文件的一些属性返回是或者否。 例如- empty 只有当当前文件为空时返回是。

Actions

Actions have side effects (such as printing something on the standard output) and return either true or false, usually basedon whether or not they are successful. The -print action for example prints the name of the current file on the standard output.

Actions 具有副作用( 比如 打印一些东西到标准输出),并且基于是否成功返回是或者否。例如 - print 选项 将当前文件的名字打印到标准输出。

Global options

Global options affect the operation of tests and actions specified on any part of the command line. Global options always return true. The -depth option for example makes find traverse the file system in a depth-first order.

全局选项会影响在命令行的任何部分上指定的测试操作和操作。 全局选项始终返回true。 例如,-depth选项使find以深度优先的顺序遍历文件系统。

Positional options

Positional options affect only tests or actions which follow them. Positional options always return true. The -regextype option for example is positional, specifying the regular expression dialect for regular expressions occurring later on the command line.

位置选项仅影响跟随选项后的 测试动作。 位置选项始终返回true。 例如,-regextype选项是位置表达式,为稍后在命令行上出现的正则表达式指定正则表达式方言。

Operators

Operators join together the other items within the expression. They include for example -o (meaning logical OR) and -a (meaning logical AND). Where an operator is missing, -a is assumed.

运算符将其它条目加入到表达式中。他们包括 -o 代表逻辑与, -a 代表逻辑或。当缺失运算符时,总是假设为 -a的。

If the whole expression contains no actions other than -prune or -print, -print is performed on all files for which the whole expression is true.

如果整个表达式除-prune或-print之外均不包含其他操作,则对整个表达式为true的所有文件执行-print。

6. 常用的表达式选项

Tests

  • -name pattern
  • -mmin n
    File’s data was last modified n minutes ago.
  • -size n[cwbkMG]
  • -uid
  • -empty

GLOBAL OPTIONS

  • -depth
    Process each directory’s contents before the directory itself. The -delete action also implies -depth.
  • -maxdepth

ACTIONS

  • -print
  • -print0

OPERATORS

  • !
  • -a
  • -o
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值