find命令

-newer

1
2
3
4
5
6
7
8
#查找当前目录下比abc.txt晚的文件或目录
find  ./ -newer abc.txt

#查询当前目录下比abc.txt晚的文件
find ./ -type f -newer abc.txt

#查找当前目录下比log目录晚的目录(目录必须用目录做对比)
find ./ -type d -newer log

-maxdepth

1
2
#查找时定义目录深度[数字代表深度]
find ./ -maxdepth 1

排除目录

可以使用-prune或者-not -path 又或者是 ! -path

查找0字节或空文/件空目录

1
2
3
4
5
6
#0字节
find -type f -size 0c
#空文件
find -type f -empty
#空目录
find -type d -empty