将二进制文件从 /sourcedir 及其子目录复制到 /destdir

copy binaries from /sourcedir and its subdirs to /destdir

将所有二进制文件从 /sourcedir 复制到 /destdir。基本上,所有具有:无扩展名的文件,以及所有具有 *.a、*.so、*.ko 的文件,都从复制中排除:*.c、*.h 文件。从除名为 "excludeDir".

的子目录之外的所有子目录中复制文件

我尝试了 bash 中的以下方法:

find /my/sourcedir/ -mindepth 2 -type f -not -iname "excludeDir" -or "*.c" -or "*.h" -or "makefile" -print -exec cp {} /my/destdir \;

bash 产生以下错误:

find: paths must precede expression: `*.c'

该命令在尝试排除 files/sub-directory 之前不会抛出错误。

-name pattern 后面的文件名上找到预期条件。这对于 '*.c'、'*.h' 和 'Makefile' 项是必需的。 (格式化只是为了便于阅读,所有内容都在一行上)。

find /my/sourcedir/ -mindepth 2 -type f -not '(' -iname "excludeDir"
    -or -name '*.c'
    -or -name '*.h'
    -or -name "makefile" ')' -print -exec cp {} /my/destdir \;