2021-5-10linux-find命令

------------find命令--------------------
命令格式:find [-H] [-L] [-P] [-D debugopts] [-Olevel]
[starting-point…] [expression]

starting-point为一个起点列表,可以多个起点
expression:This is a kind of query specification describing
how we match files and what we do with the files that were matched.
主要使用的有test部分和action部分
1 test部分(expression中的一种),是用来返回一个true或false的值的表达式的,为true的话,就可以显示出来

  • 比较常用的amin n,atime n,anewer reference 分别表示访问时间(access)在n分钟之前,n天之前,
    在reference修改之前的文件.
    与之类似的,还有

  • cmin, ctime, cnewer 表示change时间

  • mmin,mtime,newer 表示modified时间,修改时间

  • empty表示空文件,并且是普通文件或者目录。

  • executable表示可执行文件

  • name更加常用,后面可以是一个pattern

  • size可以根据大小查找 -size n[cwbkMG]
    c表示bytes,w表示2bytes,b表示512bytes,k表示kB,M表示MB,G表示GB

  • type可以根据类型 b,c,d,p,f(常规文件),l,s,D

  • gid,group可以根据组来查找

  • uid,user根据用户查找

注意:
不同test expression之间可以加上逻辑运算符

  • -not 表示非 -not exp/
  • !exp
  • -and 表示与 exp -and exp
  • -or 表示或 exp -or exp

2 Actions
Actions have side effects (such as printing something on the standard
output) and return either true or false, usually based on whether or not
they are successful. The -print action for example prints the name of
the current file on the standard output.
使用
-exec 执行的命令 ;
可以对每一个前面test后的文件进行动作的触发。但是注意最后要加上反斜杠和分号。命令里面的{}可以表示前面传过来的文件名。跟预设的变量一个作用。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值