find 命令关于修改和创建等时间

-mtime n  指的是 n 天前修改的文件,如果是-n 则表示n天前到当前修改的文件,如果是+n则表示n天前以及大于n天前的数据

1. 找出当前目录下最新3天修改过得文件
 find . -mtime -3
2.找出昨天修改过得文件
find . -mtime 1
3.找出最新3天都没有修改过得文件
find . -mtime +3
4  最近24小时内改过的文件
find . -mtime 0
5. 找出固定某天修改过得文件
这就需要用到另一个选项newerXY, 其中XY是替换选项可选的值都为:
a: 读取时间
c: 创建时间
m:修改时间
t: 以时间戳方式比较

[leo@hadoop ~]$ find . -newermt 20130801 -exec ls -l {} \;

6. 只检索当前目录的文件不检索子目录下的文件
[leo@hadoop ~]$ find . -maxdepth 1 -newermt 20130801 -exec ls -l {} \;

7.某个用户的文件
[leo@hadoop ~]$ find . -user leo

8.某种类型文件
[leo@hadoop ~]$ find . -type f

9. 检索并且处理文件
[leo@hadoop ~]$ find . -type f -exec ls -l {} \;

{} 代表检索出来的文件(包含路径), \;是固定的结束转义,记得空格

10 逻辑取反 (!)
[root@localhost simulation]# find . !  -name "sale*" -print
.
./auto.sh
./department.txt
./myname.txt
./error.txt
./province.txt
./product.txt
./allsale.txt

11. 逻辑与(默认)
[root@localhost simulation]# find . !  -name "sale*" -name "all*" -print
./allsale.txt
[root@localhost simulation]# find . !  -name "sale*" -a -name "all*" -print
./allsale.txt


12 逻辑或
[root@localhost simulation]# find .  -name "all*" -print  -o -name "err*" -print
./error.txt
./allsale.txt

13 当有多重的逻辑运算 用括号而且用转义,注意括号前后的空格
[root@localhost simulation]# find .  -name "*.txt"  -a  \( -name "error*"  -o -name "all*"  \) -print
./error.txt
./allsale.txt
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值