【问题标题】:Equivalent of 'find' for finding directories in the linux terminal?相当于在 linux 终端中查找目录的“find”?
【发布时间】:2015-09-26 14:40:55
【问题描述】:

是否有类似 'find' 之类的实用程序来代替在 linux/unix 终端中查找具有用户指定名称的目录(或 find 中可以启用相同功能的选项)?

【问题讨论】:

  • find 可以仅限于打印目录。请参阅-type 谓词。
  • 如果不区分大小写,请使用find . -type d -name "*something*" 或-iname "*something*"。

标签: linux shell unix terminal command


【解决方案1】:

您可以为此使用find 加上选项-type d(d = 仅目录,f 将仅返回文件)。

使用-name "pattern" 搜索区分大小写。 pattern 可以包含*(任意数量的未知字符,包括无)或?(正好是一个任意字符)。

使用-iname "pattern" 搜索不区分大小写。

例子:

find /home -type d -iname "public*html"

将在/home 下的任何位置找到public_html、publichtml 或PublicHtml

相关:

【讨论】:

  • 如果该选项定位的对象被称为“文件夹”,则该选项不会被命名为“d”。它会找到目录。
猜你喜欢
  • 2020-07-27
  • 2015-01-17
  • 2013-12-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多