1.根据文件名或正则表达式匹配搜索

-name:指定文件名所必须匹配的字符串

-print:在终端中打印出符合条件的文件名或文件路径

eg:find / -name "*.txt" -print

[root@test home]# find /home -name "*.txt" -print

/home/example.txt

/home/file.txt

/home/EXAMPLE.txt

2.否定参数

eg find .! -name "*.txt" -print

[root@test home]# ls

1.sh example.txt EXAMPLE.txt file.txt

[root@test home]# find . ! -name "*.txt" -print

.

./1.sh

3.指定目录的深度搜索

-maxdepth:指定最大深度

-mindepth:指定遍历的最小深度

eg:find . -maxdepth 2 -type f -print

find . -mindepth 1 -type f -print

[root@test home]# find . -maxdepth 2 -type f -print

./1.sh

./example.txt

./file.txt

./EXAMPLE.txt

4.根据文件类型搜索

eg:find . -type f -print

[root@test home]# find . -type f -print

./1.sh

./example.txt

./file.txt

./EXAMPLE.txt

5.根据文件时间进行搜索

-newer:指定一个用于比较时间戳的参考文件

eg: find . -type f -atime +7 -print

find . -type f -newer file -print

6.基于文件大小的搜索

eg:find . -type f -size -2k -print

[root@test home]# find . -type f -size -2k -print

./1.sh

./example.txt

./file.txt

./EXAMPLE.txt

7.删除匹配的文件

-delete:可以用来删除find查找到的匹配文件

eg:find . -type f -name "file.txt" -delete -print

8.基于文件权限和所有权的匹配

eg:find . -type f -perm 644 -print

[root@test home]# find . -type f -perm 644 -print

./1.sh

./example.txt

./EXAMPLE.txt

9.结合find执行命令

eg: find . -type f -name "example.txt" -user root -exec cp -rfp /tmp {} \;