【问题标题】:bash: How do I selectively copy directories from one tree to another?bash:如何有选择地将目录从一棵树复制到另一棵树?
【发布时间】:2020-04-12 10:07:38
【问题描述】:

我的目录树看起来有点像这样:

/Volumes/Data/TEMP/DROP
├───R1
│   ├───morestuff
│   │   └───stuff2
│   │       └───C.tool
│   └───stuff
│       ├───A.tool
│       └───B.Tool
└───R2
    ├───morestuff
    │   └───stuff2
    │       └───C.tool
    └───stuff
        ├───A.tool
        └───B.Tool

如何将*.tool 目录从R1 递归复制到(覆盖)R2 中的目录?我的 bash 已经生锈了大约 20 年。

【问题讨论】:

标签: bash


【解决方案1】:

这会起作用(扩展@Maxim Egorushkin 的想法)


# The trailing slash important in the next line
SOURCE=/Volumes/Data/TEMP/DROP/R1/
DEST=/Volumes/Data/TEMP/DROP/R2
rsync -zarv --include "*/" --include="*.tool" --exclude="*" "$SOURCE" "$DEST"


【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多