我有以下问题:
我必须写一些东西来复制目录A中包含的文件。该文件是唯一的,并且具有特定的扩展名(.jil)。唯一的问题是,目录A可以包含一个子目录B(可以包含一个子目录C,...),然后我的文件就不会位于目录A中,而是位于他的一个子目录中。
我可以使用什么命令来查找此文件而不浏览我的所有目录?
这实际上是find
默认情况下的工作方式。你可以跑
find A/ -name "*.jil" -exec cp {} target_dir/ \;
的默认行为find
是递归查看所有子目录,您可以通过设置-maxdepth
/-midepth
选项来控制它:
-maxdepth levels
Descend at most levels (a non-negative integer) levels of direc‐
tories below the command line arguments. -maxdepth 0
means only apply the tests and actions to the command line
arguments.
-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 command line arguments.
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句