検索コマンドの出力が期待した結果を提供しません。

検索コマンドの出力が期待した結果を提供しません。

ファイルの作成

touch a1.txt a2.txt a3.txt
touch s1.mp3 s2.mp3 s3.mp3

だから私はやる

find . -name "*.txt" -or -type f -print

そして、なぜファイルs1.mp3 s2.mp3 s3.mp3が表示されないのですか?.txt

ベストアンサー1

演算子の優先順位のため:絶対的なAND間のAND()は-aOR()よりも優先順位が高くなります。-type f-print-o

find . \( -name "*.txt" \) -or \( -type f -print \)

欲しいかもしれないけど

find . \( -name "*.txt" -or -type f \) -print

すべてのファイルを印刷します。

おすすめ記事