【问题标题】:Bash find prune isn't working as intendedBash find prune 没有按预期工作
【发布时间】:2018-12-10 08:32:45
【问题描述】:

我有几个 git 存储库,我想计算它们包含多少 .txt、目录和其他文件。问题是每个存储库内都有一个包含更多文件和配置的 .git 目录。我也不想计算我正在寻找的文件夹,或 .git 目录或其包含的文件。我使用以下命令:

all="$(find $repo -path "$repo"/.git -prune -o type f)"
dirs="$(find $repo -path "$repo"/.git -prune -o type d)"
txts="$(find $repo -path "$repo"/.git -prune -o type f -iname "*.txt")"

$repo 是我的存储库的路径,它看起来像 assignments/repo1 assignments/repo2 等。 所有这些 find 迭代仍在 .git 内部并在那里列出所有内容。我是在犯语法错误还是什么?

【问题讨论】:

  • 你的意思是$repo 包含两个目录吗?

标签: linux bash shell find


【解决方案1】:

感谢您的回复。我无法让-path 工作,所以我将其切换到-name。我还使用了"$repo"/* 中的查找,我认为解决了它。我没有尝试过,但我相信如果我将-path"$repo"/* 一起使用会有效。

【讨论】:

    猜你喜欢
    • 2016-12-24
    • 2012-04-12
    • 1970-01-01
    • 2012-03-14
    • 1970-01-01
    • 2012-05-10
    • 2016-02-24
    • 1970-01-01
    • 2014-10-15
    相关资源
    最近更新 更多