文件查找工具find

查找多个匹配条件(or)的文件

有时候我们需要查找 匹配A 或者 匹配B 的文件,例如,我们需要找到 *.py*.html 文件,则 find 工具也提供了一个 -o 参数表示 or 来连接多个参数:

find Documents \( -name "*.py" -o -name "*.html" \)

例如,我在 iso镜像使用location参数进行virt-install安装虚拟机 找多个文件

查找控制递归目录深度

默认情况下, find 会搜索指定目录的所有子目录(递归),但是有时候我们就是要限定目录深度,此时可以使用参数 --maxdepth 1 选项:

find命令控制递归目录深度
# Do NOT show hidden files (beginning with ".", i.e., .*):
find DirsRoot/* -maxdepth 0 -type f

#  DO show hidden files:
find DirsRoot/ -maxdepth 1 -type f

参考