bash:如何选择性地将目录从一棵树复制到另一棵树

  • 本文关键字:一棵树 复制 选择性 bash bash
  • 更新时间 :
  • 英文 :


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

/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年的铁锈。

这将起作用(扩展@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"

最新更新