一个子目录目录同步忽略 [英] Directory Sync with a Subdirectory to Ignore

查看:129
本文介绍了一个子目录目录同步忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做一个目录同步例如从 / DIR-A / / DIR-B / (总是在这个方向上)。然而,有两个要求:

I need to do a directory sync e.g. from /dir-a/ to /dir-b/ (always in this direction). However, there are two requirements:


  1. 有一个特定的子目录 /dir-a/.dont-copy / (是的,开始与)我应该忽视的。也就是说, /dir-a/.dont-copy / 应该总是停留在 / DIR-A / ,从来没有移动。

  2. 文件/目录 / DIR-B / 不存在中 / DIR-A / 应被删除。​​

  1. There is a particular subdirectory /dir-a/.dont-copy/ (yes, started with a .) that I should ignore. That is, /dir-a/.dont-copy/ should always stay in /dir-a/, never move.
  2. Files / directories in /dir-b/ that don't exist in /dir-a/ should be deleted.

我将如何做到这一点使用的命令行工具(理想情况下,在Mac OSX)?预先感谢您的帮助!

How would I do this using command-line tools (ideally, on Mac OSX)? Thanks beforehand for your help!

推荐答案

尝试:


$ rsync -avz --exclude=.dont-copy --delete dir-a/ dir-b

请注意在DIR-一个尾随斜线。如果省略,您将得到DIR-B / DIR-A。

Note the trailing slash on dir-a. If you omit that, you will get dir-b/dir-a.

这篇关于一个子目录目录同步忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆