を使用して1つのディレクトリを除外して、パターンに一致するすべてのファイルとディレクトリを見つけるにはどうすればよいfind
ですか?
次のファイル構造があるとします。
。 foo-exclude-me / foo.txt foo-exclude-me-not / foo.txt バー/ foo.txt foobar / bar.txt foofoo.txt
を使用して次の出力をどのように取得しますかfind
:
./bar/foo.txt ./bar/foobar ./bar/foobar/foofoo.txt ./foo-exclude-me-not ./foo-exclude-me-not/foo.txt
次のコマンドの両方を使用してみました:
見つける。-name 'foo-exclude-me' -prune -o -name 'foo *' 見つける。-name 'foo *' \!-path './foo-exclude-me/*'
しかし、どちらもこれを返します:
./bar/foo.txt
./bar/foobar
./bar/foobar/foofoo.txt
./foo-exclude-me # << this should be excluded
./foo-exclude-me-not
./foo-exclude-me-not/foo.txt
foo-exclude-me
ディレクトリを適切に除外するにはどうすればよいですか?
@MaxMackieパーフェクト:)
—
Tyilo
直した?あなたのために働いた修正はどれでしたか?コメントの代わりに答えに入れることができます。
—
n0pe 2013年
@MaxMackieの両方
—
Tyilo
-print
をfoo-exclude-me
使用し./foo-exclude-me
ます。
素晴らしいですが、Gillesが私を倒したように見えます:)
—
n0pe 2013年
foo-exclude-me
代わりに使用してみてください./foo-exclude-me
。また-print
、コマンドの最後に追加してみてください。