我想知道最大深度和最小深度如何与 find 命令一起使用。
还想知道下面的命令是如何工作的,
find . -mindepth 2 -maxdepth 5 -name 'file1'
根据find 的手册页
-maxdepth levels
Descend at most levels (a non-negative integer) levels of
directories below the starting-points. -maxdepth 0 means only
apply the tests and actions to the starting-points themselves.
-mindepth levels
Do not apply any tests or actions at levels less than levels
(a non-negative integer). -mindepth 1 means process all files
except the starting-points.
so -mindepth
意味着您将获得所有文件/目录,将当前级别计为 1,将第一级目录计为 2,依此类推。
-maxdepth
意思是你应该搜索对象的最大深度是多少,当前的深度为0
所以如果我们有这样的结构:
.
file1
dir1
file1
dir2
file1
dir3
file1
dir4
file1
dir5
file1
在您的示例中,我们将搜索名为的对象file1
in dir1
并低于dir5
。所以不会找到第一个file1
(点下)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)