Unix 终端错误 - "cp: the -R and -r options may not be specified together."

Unix Terminal error - "cp: the -R and -r options may not be specified together."

我在 os-x unix 上有 bash 脚本 运行 上面的命令:

cp -avr source destination

结果出现以下错误:

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

当我删除 a 标志时,它工作正常,没有错误。

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

谢谢,

查看 cp 的手册页:

-a, --archive same as -dR --preserve=all

-R, -r, --recursive copy directories recursively

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

cp -dRvr --preserve=all source destination

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

cp -av source destination