-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
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