gpt4 book ai didi

macos - MAC : How to merge folder so that we only overwrite when source files is newer than destination files?

转载 作者:行者123 更新时间:2023-11-29 09:02:08 25 4
gpt4 key购买 nike

这似乎是非常基本的命令。然而,即使搜索了一个小时的解决方案,我仍然找不到有效的方法。

所以我有两个大文件夹(有很多文件和很多子文件夹,大型备份)。我想将这两个文件夹合并到一个只包含较新文件的文件夹中。所以我正在寻找一种覆盖文件的方法,如果只有源文件比目标文件新,或者目标文件不存在。

我运行的是 Mac 版本 10.7.4。我愿意安装新应用程序和/或使用终端/bash 命令。

最佳答案

在 Gnu 系统中,使用 mv -u SOURCE DESTcp -u SOURCE DEST 仅在源文件比 DEST 文件更新或当目标文件丢失。

请注意,在 OS X 中,mvcp不支持 -u 选项。然而,rsync有一个 -u 选项,它在 OS X 上受支持。例如:

rsync -aru SOURCE/ DEST

在将它应用到大型和重要目录之前,先在临时目录中运行一些测试,因为 (IMO) rsync 在目录名称是否以 / 结尾方面是特殊的。 Linux 手册页的一部分说:

A trailing slash on the source changes this behavior to avoid creating an additional directory level at the destination. You can think of a trailing / on a source as meaning "copy the contents of this directory" as opposed to "copy the directory by name", ...

关于macos - MAC : How to merge folder so that we only overwrite when source files is newer than destination files?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14306832/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com