【发布时间】:2010-09-06 19:48:21
【问题描述】:
【问题讨论】:
【问题讨论】:
考虑:
-maxdepth n
True if the depth of the current file into the tree is less than
or equal to n.
-mindepth n
True if the depth of the current file into the tree is greater
than or equal to n.
【讨论】:
生日,
只是想扩展 Jon 使用 -prune 的建议。它不是最容易使用的查找选项,例如仅在当前目录中搜索查找命令如下所示:
find . \( -type d ! -name . -prune \) -o \( <the bit you want to look for> \)
这将阻止 find 下降到该目录中的子目录。
基本上,它说,“修剪任何名称不是“.”的目录,即当前目录。”
find 命令对当前目录中找到的每个项目从左到右进行评估,因此在完成第一个元素(即修剪段)后,它将继续使用第二个 -o(OR'd)中的匹配项目表达。
HTH。
干杯, 抢
【讨论】:
使用通配符可能会更好。例如,如果您想在当前目录中查找所有 ksh 脚本:
$ ls *.ksh
【讨论】:
使用 -prune 选项。
【讨论】:
你甚至可以这样做
echo /specific/dir/*.jpg
因为扩展通配符的是您的外壳。打字
ls *.jpg
相当于打字
ls foo.jpg bar.jpg
假设 foo.jpg 和 bar.jpg 是当前目录下所有以“.jpg”结尾的文件。
【讨论】: