按文件名查找
[root@192 root1]# pwd
/home/root1
[root@192 root1]# ll
total 4
-rw-r--r--. 1 hdfs hdfs 400 Aug 8 01:18 asd.java
-rw-r--r--. 1 root root 0 Aug 11 20:15 test1.txt
-rw-r--r--. 1 root root 0 Aug 11 20:15 test2.TXT
-rw-r--r--. 1 hdfs hdfs 0 Aug 11 20:15 test3.txt
drwxr-xr-x. 2 root root 6 Aug 11 20:15 testdir
# 在当前目录下查找名为test1.txt的文件
[root@192 root1]# find ./ -name "test1.txt"
./test1.txt
# 在当前目录下查找开头为test的文件和目录
[root@192 root1]# find ./ -name "test*"
./testdir
./test1.txt
./test3.txt
./test2.TXT
# 在当前目录下查找结尾是.txt的文件
[root@192 root1]# find ./ -name "*.txt"
./test1.txt
./test3.txt
# 不区分大小写
[root@192 root1]# find ./ -iname "*.txt"
./test1.txt
./test3.txt
./test2.TXT
# 在根目录下查找结尾是.TXT的文件
[root@192 root1]# find / -name "*.TXT"
/usr/share/doc/freetype-2.4.11/FTL.TXT
/usr/share/doc/freetype-2.4.11/GPLv2.TXT
/usr/share/doc/freetype-2.4.11/LICENSE.TXT
/home/root1/test2.TXT
按类型查找
# d代表找目录,f代表找文件
[root@192 root1]# find ./ -type d
./
./testdir
[root@192 root1]# find ./ -type f
./asd.java
./test1.txt
./test3.txt
./test2.TXT
按用户或用户组搜索
[root@192 root1]# find ./ -user root
asd.java
test1.txt
[root@192 root1]# find ./ -group hdfs
./test1.txt
./test2.TXT
按时间查找
三个参数,分别是:a(访问时间 Access time),m(修改时间(内容) Modify time),c(变更时间(状态) Change time)
find ./ -[a|m|c]min +n # 第n分钟之前[访问|编辑|变更]过的文件
find ./ -[a|m|c]min -n # 第n分钟之内[访问|编辑|变更]过的文件
find ./ -[a|m|c]time +n # 第n天之前[访问|编辑|变更]过的文件
find ./ -[a|m|c]time -n # 第n天之内[访问|编辑|变更]过的文件