【问题标题】:copy binaries from /sourcedir and its subdirs to /destdir [closed]将二进制文件从 /sourcedir 及其子目录复制到 /destdir [关闭]
【发布时间】:2019-12-04 17:38:29
【问题描述】:

将所有二进制文件从 /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 产生以下错误:

查找:路径必须在表达式之前:`*.c'

在尝试排除文件/子目录之前,该命令不会引发错误。

【问题讨论】:

标签: bash binaries


【解决方案1】:

在文件名上查找预期条件以遵循-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 \;

【讨论】:

  • 命令行工具的使用(对于不是软件开发特定的工具)无论如何都不是 SO 的主题。
  • 谢谢,已经够接近了。这是有效的。 code find /my/sourcedir/ -mindepth 2 -type f -not ( -iname "excludeDir" -or -iname '.c' -or -iname '.h' -or -iname '.ssh' -or -iname "Makefile" ) -exec cp {} /my/destdir \;
猜你喜欢
  • 2016-04-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-20
  • 1970-01-01
  • 2011-11-19
相关资源
最近更新 更多