不递归查找 [英] find without recursion

查看:16
本文介绍了不递归查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以以某种方式使用 find 命令,它不会递归到子目录中?例如,

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

find DirsRoot --do-not-recurse -type f 这样的结果只会是 File1, File2?

And the result of something like find DirsRoot --do-not-recurse -type f will be only File1, File2?

推荐答案

我想你会根据你当前的命令结构使用 -maxdepth 1 选项得到你想要的.如果没有,您可以尝试查看 手册页 for 找到.

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.

您的选择基本上是:

# Do NOT show hidden files (beginning with ".", i.e., .*):
find DirsRoot/* -maxdepth 0 -type f

或者:

#  DO show hidden files:
find DirsRoot/ -maxdepth 1 -type f

这篇关于不递归查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆