Unix终端错误-“ cp:-R和-r选项可能未一起指定。”

mic*_*ael -1 unix linux terminal cp

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

cp -avr source destination

结果是以下错误:

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

当我删除该a标志时,它可以正常运行而不会出错。

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

谢谢,

kam*_*uel 5

看看手册页cp

-a,--archive与-d R --preserve = all

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

因此,通过指定-a,您基本上可以说:

cp -dRvr --preserve=all source destination
Run Code Online (Sandbox Code Playgroud)

您同时拥有-R-r,并且由于这两个相同,因此会警告您。要解决此问题,只需删除-r

cp -av source destination
Run Code Online (Sandbox Code Playgroud)

  • @michael - 当您指定 `-a` 时,就意味着 `cp` 将递归运行。 (2认同)