【问题标题】:Unix Terminal error - "cp: the -R and -r options may not be specified together."Unix 终端错误 - “cp:不能同时指定 -R 和 -r 选项。”
【发布时间】:2015-09-21 12:33:45
【问题描述】:

我在 os-x unix 上使用上述命令运行 bash 脚本:

cp -avr source destination

结果如下错误:

cp: the -R and -r options may not be specified together.

当我删除 a 标志时,它可以正常工作而不会出现错误。

这个错误的原因和含义是什么?

谢谢,

【问题讨论】:

  • @KurzedMetal 我不明白你的评论
  • @michael - 他/她的意思是您将在文档中找到问题的答案 - 确切地说是在手册中。如果您在 shell 中输入“man cp”,您将看到对 cp 接受的所有开关的描述。这是明智的做法——在提问之前先阅读手册。 RTFM 本身的意思是“阅读 f*** 手册”,但不要被它冒犯,这是一个常见的短语,我们都听过几次 :D

标签: linux unix terminal cp


【解决方案1】:

查看cp 的手册页:

-a, --归档 等同于 -dR --preserve=all

-R, -r, --recursive 递归复制目录

所以通过指定-a,你基本上说:

cp -dRvr --preserve=all source destination

你同时拥有-R-r,因为这两个是相同的,所以它会警告你。要解决这个问题,只需删除 -r:

cp -av source destination

【讨论】:

  • 但我需要 r 进行递归
  • @michael - 当您指定-a 时,这已经意味着cp 将递归操作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-18
  • 2019-12-11
  • 1970-01-01
  • 2015-02-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多