すべてのバイナリを/ sourcedirとそのサブディレクトリから/ destdirにコピーしたいと思います。基本的に、拡張子のないすべてのファイル、および* .a、*。so、*。koのあるすべてのファイル、およびコピーから除外するファイル:Makefileおよび* .depend。「excludeDir」という名前のサブディレクトリからファイルコピーを除外します。このコマンドは、すべてのバイナリを1つのフォルダに配置する必要があります。
私はbashから次のことを試しました:
find /my/sourcedir/ -mindepth 2 -type f -not -iname "excludeDir" -or "*.c" -or "*.h" -or "makefile" -print -exec cp {} /my/destdir \;
bashスクリプトは次のエラーを生成します:
検索:パスは式の前に置く必要があります: `* .c '
私に問題を引き起こしている部分は除外です(ファイル:*。h、*。c、Makefile、およびサブディレクトリ: "excludeDir")
mjb2kmnのアドバイスを使用すると、グロブを除いて次のコマンドが適切に機能します。
find /opt/ppmac-exp/ -mindepth 2 -not -iname *.c -not -iname *.cpp -not -iname *.cc -not -iname *.cs -not -iname *.h -not -iname *.cfg -not -iname *.sh -not -iname *.layout -not -iname *.depend -not -iname Makefile -not -iname Makefile* -type f -print -exec cp {} /opt/build \;
...スタックオーバーフローのmjb2kmnとdash-oの助けを借りて、これは機能し、グロブを防ぎました。皆さん、ありがとうございました!
find /my/sourcedir/ -mindepth 2 -type f \( -not -iname "excludeDir" -not -iname '*.c' -not -iname '*.h' -not -iname '.ssh' -not -iname "Makefile" \) -exec cp {} /my/destdir \;
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加