AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1860302
Accepted
Joce
Joce
Asked: 2024-10-31 00:52:55 +0800 CST2024-10-31 00:52:55 +0800 CST 2024-10-31 00:52:55 +0800 CST

`cp --update` 会从目标中删除文件吗?

  • 772

我正在使用它cp -ruv sourcedir/ /mnt/destinationdir来轻松维护文件树的备份。

有时,此命令会告诉我:

remove '/mnt/destinationdir/path/file'

我很惊讶,因为man cp说:

   --update[=UPDATE]
          control which existing files are updated;
          UPDATE={all,none,none-fail,older(default)}.

   -u     equivalent to --update[=older].  See below


   UPDATE controls which existing files in the destination are
   replaced.  'all' is the default operation when an --update option
   is not specified, and results in all existing files in the
   destination being replaced.  'none' is like the --no-clobber
   option, in that no files in the destination are replaced, and
   skipped files do not induce a failure.  'none-fail' also ensures
   no files are replaced in the destination, but any skipped files
   are diagnosed and induce a failure.  'older' is the default
   operation when --update is specified, and results in files being
   replaced if they're older than the corresponding source file.

何时会cp --update=older删除目标目录中的所有文件?

编辑:上面的摘录针对的man cp是 coreutils 9.5,我实际上使用的是 9.1,它具有较少的更新控制,但从该手册页来看,我猜它的行为不应该有所不同。

linux
  • 1 1 个回答
  • 13 Views

1 个回答

  • Voted
  1. Best Answer
    music2myear
    2024-10-31T00:59:19+08:002024-10-31T00:59:19+08:00

    是的,--update保持目的地与源同步,它不是一个备份选项。

    older表示进程检查对象是否已更改的主要标志是日期。如果源对象的创建/修改日期较新(目标对象的创建/修改日期较旧),则替换目标对象。

    保持目标与源同步意味着在源中已删除或更改的对象将在目标中被删除或更改。备份会保留在源中已删除的对象,并保留在源中已更改的对象的先前版本。

    同步的目的是保留两个(或更多)可用的文件副本。它更多的是冗余或弹性,而不是备份。

    • 1

相关问题

  • 如何让我的 Linux 机器看起来像是在运行 Windows?

  • 对于 cp 或 mv,是否有等同于 cd - 的东西?

  • 以 root 身份运行 docker 容器

  • 如何在域和 Linux 活动目录中启用指纹传感器

  • 如何在CentOS 7 中将Ctrl+C 永久更改为Ctrl+K?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve