发现没有递归 [英] find without recursion
本文介绍了发现没有递归的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能以某种方式使用 find
命令不会递归到子目录中?例如,
DirsRoot
| - > SubDir1
| | -OtherFile1
| - > SubDir2
| | -OtherFile2
| -File1
| -File2
例如 find DirsRoot --donotrecuourse -type f
将只是 File1,File2
?
-maxdepth 1
选项,根据你的当前命令结构。如果没有,您可以尝试查看<$ c的手册页 $ p
$ b
=lang-none prettyprint-override>-maxdepth级别
在命令行参数下面的大部分级别(非负整数)级别的direc-
下降。 `-maxdepth 0'表示
只将测试和操作应用到命令行参数中。
您的选项基本上是:
find DirsRoot / * -maxdepth 0 -type f#这不显示隐藏文件
或
$ b $ pre $find DirsRoot / -maxdepth 1 -type f#这个显示隐藏文件
Is it possible to use the find
command in some way that it will not recurse into the sub-directories? For example,
DirsRoot
|-->SubDir1
| |-OtherFile1
|-->SubDir2
| |-OtherFile2
|-File1
|-File2
And the result of something like find DirsRoot --donotrecuourse -type f
will be only File1, File2
?
解决方案
I think you'll get what you want with the -maxdepth 1
option, based on your current command structure. If not, you can try looking at the man page for find
.
Relevant entry (for convenience's sake):
-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.
Your options basically are:
find DirsRoot/* -maxdepth 0 -type f #This does not show hidden files
Or:
find DirsRoot/ -maxdepth 1 -type f #This does show hidden files
这篇关于发现没有递归的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文