【问题标题】:How to ignore `.*` folders and files when using `find` command? [closed]使用`find`命令时如何忽略`.*`文件夹和文件? [关闭]
【发布时间】:2019-01-05 10:08:57
【问题描述】:

我正在运行find . -depth -empty 来查找空文件夹和空文件。

但是很多.*文件夹和文件应该被忽略,比如.git,.gitignore,.nbproject...
如何编写脚本以在find 命令中忽略.*

【问题讨论】:

标签: bash find


【解决方案1】:

我相信有几种方法可以做到这一点,例如:

find . \( ! -regex '.*/\..*' \) -type f -name "something"

第一个示例不会显示任何隐藏文件或目录。

find . \( ! -regex '.*/\..*/..*' \) -type f -name "something"

第二个只是丢弃隐藏目录,将隐藏文件显示到正常目录中。

是find的正则表达式选项。

这里有完整的解释:find command search only non hidden directories

编辑 1:

find . -type f -not -name ".*"

【讨论】:

    猜你喜欢
    • 2010-10-30
    • 2016-05-22
    • 1970-01-01
    • 2018-01-12
    • 1970-01-01
    • 1970-01-01
    • 2017-06-22
    • 2013-12-24
    • 1970-01-01
    相关资源
    最近更新 更多