最大深度和最小深度如何使用find命令? [英] How maxdepth and mindepth works with find command?
本文介绍了最大深度和最小深度如何使用find命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何使用find命令来执行maxDeep和minDeep。 我还想知道下面的命令是如何工作的
find . -mindepth 2 -maxdepth 5 -name 'file1'
推荐答案
-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.
所以-mindepth
表示将所有文件/目录计算为当前级别为1,将第一级目录计算为2,依此类推。
-maxdepth
表示应该搜索对象的最大深度是多少,当前对象算作0
所以如果我们有如下结构:
.
file1
dir1
file1
dir2
file1
dir3
file1
dir4
file1
dir5
file1
在您的示例中,我们将搜索file1
中名为file1
以及dir5
以下的对象。因此将找不到第一个file1
(点下)
这篇关于最大深度和最小深度如何使用find命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文