如何将两个目录的差异复制到新目录?
假设我有两个目录:D1 和 D2。
D1(f1、f2、f3、f4) D2 (f1, f2)
我想将 D1 中不在 D2 中的文件复制到另一个目录 D3:
D3 (f3, f4)
在 Linux 中如何执行此操作?
谢谢, 三位一体
Suppose I have two directories : D1 and D2.
D1 ( f1, f2, f3, f4 )
D2 ( f1, f2 )
I want to copy the files in D1 , which are not in D2, to another directory D3 :
D3 ( f3, f4 )
How do I do this in linux ?
Thanx,
trinity
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看看“dirdiff”包。它允许您做您想做的事情。
或者,这个 bash 命令行应该这样做:
注意 ls D1 周围的反引号 - 而不是单引号! (在美国键盘上,它位于〜(波形符)下方)
Look at the 'dirdiff'-package. It allows for what you want to do.
Alternatively, this bash command-line should do it:
Note the back-ticks around
ls D1
- not single quotes! (On the US-keyboard it is beneath the ~(tilde))从 D1 复制到 D3 时使用 -exclude 指定 D2
这将会完成...
while copying from D1 to D3 use -exclude specifying D2
and it would be done...
刚刚花了一天的大部分时间整理了类似的内容,并从一个旧的问题的答案中找到了答案。我最终得到了一个相当复杂的 bash 脚本:
Just spent a good portion of a day sorting out something similar and picked up from an answer of an older question. I ended up with a fairly elaborate bash script: