.gitを除外する必要があります 私のfindから 探す。これを実現するために、私は-path ./.git -pruneを使用しています。 スイッチ:
$ find . -path ./.git -prune -o ( -type f -o -type l -o -type d ) | grep '.git'
./.git
ただし、これは.gitディレクトリの内容をスキップしますが、ディレクトリ自体を一覧表示します。 -path ./.git -prune -o -print -aを追加すると機能します
find . -path ./.git -prune -o -print -a ( -type f -o -type l -o -type d ) | grep '.git'
なぜこれが必要なのですか。どちらのコマンドも同じ出力になるはずだと思いました。 2番目の構文はかなり醜いです。
承認された回答:
man findのページ 与える:
-prune True; if the file is a directory, do not descend into it. If
-depth is given, false; no effect. Because -delete implies
-depth, you cannot usefully use -prune and -delete together.
したがって、最初の例では、-path ./.git -pruneではありません。 は正しくないため、デフォルトのアクション(-print )は呼び出されないため、行が印刷されます。