「ファイル」ツールを「検索」の述語に置き換える方法は?

「ファイル」ツールを「検索」の述語に置き換える方法は?

私は次のようなものがあります:

find . -type f -print0  | xargs -0 file | grep Matroska | cut -d: -f 1-1 | xargs rm

私は次のようなものが欲しい:

find . -type -f -filemagic "Matroska" -delete

ベストアンサー1

bashオプションを使用して内部およびシェル内で実行できます。たとえば、次のようになります。find-execfile

find . -type f -execdir bash -c 'file "$0" | grep -q Matroska && rm "$0"' {} \;

おすすめ記事