Limit Search To Specific Directory Level Using mindepth and maxdepth
Find the passwd file under all sub-directories starting from root directory.
# find / -name passwd
./usr/share/doc/nss_ldap-253/pam.d/passwd
./usr/bin/passwd
./etc/pam.d/passwd
./etc/passwd
Find the passwd file under root and one level down. (i.e root — level 1, and one sub-directory — level 2)
# find -maxdepth 2 -name passwd
./etc/passwd
Find the passwd file under root and two levels down. (i.e root — level 1, and two sub-directories — level 2 and 3 )
# find / -maxdepth 3 -name passwd
./usr/bin/passwd
./etc/pam.d/passwd
./etc/passwd
Find the password file between sub-directory level 2 and 4.
# find -mindepth 3 -maxdepth 5 -name passwd
./usr/bin/passwd
./etc/pam.d/passwd
Limit Search To Specific Directory Level Using mindepth and maxdepth
最新推荐文章于 2016-06-21 13:17:07 发布
本文介绍如何利用Linux下的find命令按特定目录层级查找文件。通过设置mindepth和maxdepth参数,可以精确控制搜索的深度范围,例如仅在一、二级目录中查找passwd文件,或是在更深的目录层级中进行搜索。
5万+

被折叠的 条评论
为什么被折叠?



