有没有什么办法prevent从挖下去递归到子目录找到? [英] Is there any way to prevent find from digging down recursively into subdirectories?

查看:121
本文介绍了有没有什么办法prevent从挖下去递归到子目录找到?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我做的:

$ find / 

它搜索整个系统。结果
我如何prevent呢?

It searches the entire system.
How do I prevent that?

(这个问题来自一个回答另一个问题。 )

(This question comes from an "answer" to another question.)

推荐答案

儿真好,

只是想在建议扩大乔恩使用-prune。这不是最简单的查找选项使用,例如只在当前目录find命令看起来像搜索:

Just wanted to expand on the suggestion from Jon to use -prune. It isn't the easiest of find options to use, for example to just search in the current directory the find command looks like:

find . \( -type d ! -name . -prune \) -o \( <the bit you want to look for> \)

这将阻止找到该目录内下降到子目录。

this will stop find from descending into sub-directories within this directory.

基本上,它说,修剪任何一个目录,名字是不是。,即当前目录下的。

Basically, it says, "prune anything that is a directory, whose name isn't ".", i.e. current dir."

find命令evals从左到右在当前目录中找到的每个项目,以便第一元件完成后,即剪枝段,它将然后继续与匹配项你的第二个-o(或运算)前pression。

The find command evals left to right for each item found in the current directory so after completion of the first element, i.e. the prune segment, it will then continue on with the matched item in your second -o (OR'd) expression.

心连心。

欢呼声,
罗布

cheers, Rob

这篇关于有没有什么办法prevent从挖下去递归到子目录找到?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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