Linux运维知识之Linux find查找文件命令详解
小标 2019-03-05 来源 : 阅读 1775 评论 0

摘要:本文主要向大家介绍了Linux运维知识之Linux find查找文件命令详解,通过具体的内容向大家展现,希望对大家学习Linux运维知识有所帮助。

本文主要向大家介绍了Linux运维知识之Linux find查找文件命令详解,通过具体的内容向大家展现,希望对大家学习Linux运维知识有所帮助。

Linux运维知识之Linux find查找文件命令详解

语法:find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path…] [expression]


选项:

-P

不跟随符号链接(默认选项)。

-L

跟随符号链接。


表达式:

表达式由options,tests,actions组成。

OPTIONS:

-daystart

Measure times (for -amin, -atime, -cmin, -ctime, -mmin, and -mtime) from the beginning of today rather than from 24 hours ago. This option only affects tests which appear later on the command line.

-version, –version

Print the find version number and exit.

-help, –help

Print a summary of the command-line usage of find and exit.

 -maxdepth levels

              Descend  at most levels (a non-negative integer) levels of directo-

              ries below the command line arguments.  -maxdepth 0

               means only apply the tests and actions to the command  line  argu-

              ments.


       -mindepth levels

              Do  not  apply  any  tests or actions at levels less than levels (a

              non-negative integer).  -mindepth 1 means process all files  except

              the command line arguments.


TESTS:

-amin n

文件最后访问时间n分钟前。

-anewer file

比file最后访问时间早。

-atime n

文件最后访问时间为 n*24前。-atime  +1表示最后访问时间至少为两天前。

-cmin n

文件状态最后修改为n分钟前。

-cnewer file

文件状态最后修改时间比file早。

-ctime n

文件状态最后修改时间为 n*24前。

-empty

文件为空,且文件为一般文件或目录。

-executable

文件为可执行文件。

-gid n

文件gid。

-group gname

文件组名。

-mmin n

文件内容n分钟前被修改。

-mtime n

文件内容n*24小时前被修改。

-name pattern

以文件名搜索文件。

-newer file

文件内容最后修改时间比file早。

-nogroup

无有效gid的文件。

-nouser

无有效uid的文件。

-path pattern

匹配路径。

-perm mode

确切的权限,如-perm 600表示查找权限为600的文件。

-perm -mode

至少包含的权限,如-perm -600表示用户对文件至少有读写权限,可以匹配600,也可以匹配640 644等。

-size n[cwbkMG]

‘b’

n个512字节的block(默认)

‘c’

字节

‘w’

双字节

‘k’

千字节

‘M’

兆字节

‘G’

千兆字节

-type c

文件类型:

b

块文件

c

字符文件

d

目录

p

FIFO文件

f

常规文件

l

符号链接文件

s

socket文件

-uid n

uid为n的文件

-user uname

用户名为uname的文件

ACTIONS:

-delete

删除文件

-exec command ;

执行的命令,{}表示找出的文件名,在不同的linux,后面的分号可以需要\;

-print

打印文件全名,以分行符分隔

-print0,以空格分隔。

-quit

立即退出,find /tmp/foo /tmp/bar -print -quit表示只列出/tmp/foo。

操作符:

( expr )

优先执行

! expr

非运算

-not expr

同 ! expr

expr1 expr2

与运算

expr1 -a expr2或者expr1 -and expr2

与运算

expr1 -o expr2 或者expr1 -or expr2

或运算


本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注系统运维Linux频道!

本文由 @小标 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved

208小时内训课程