LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1077|回复: 5

cp -r 和 cp -R 有什么区别吗?

[复制链接]
发表于 2007-5-30 15:28:40 | 显示全部楼层 |阅读模式
Although -r also performs a recursive copy, its behavior with files other than ordinary files and directories is unspecified.:confused:
发表于 2007-5-30 16:45:08 | 显示全部楼层

  1.        -R     Copy directories recursively, and do the right thing when objects other than ordinary files or
  2.               directories  are  encountered.  (Thus, the copy of a FIFO or special file is a FIFO or special
  3.               file.)

  4.        -r     Copy directories recursively, and do something unspecified with objects  other  than  ordinary
  5.               files  or directories.  (Thus, it is allowed, in fact encouraged, to have the -r option a syn-
  6.               onym for -R. However, silly behaviour, like that of the GNU 4.0 version of cp is  not  forbid-
  7.               den.)
复制代码


不过我也没看懂。
回复 支持 反对

使用道具 举报

发表于 2007-5-30 17:13:20 | 显示全部楼层
没法马上验证,印象中和字面上看,复制fifo和符号链接上有区别,-r是从fifo中读取数据,-R是复制一个fifo;-r是复制符号链接指向的文件,-R是复制一个符号链接。
回复 支持 反对

使用道具 举报

发表于 2007-5-30 22:36:05 | 显示全部楼层
Post by koala114
Although -r also performs a recursive copy, its behavior with files other than ordinary files and directories is unspecified.:confused:

这种问题还是直接查手册来得准确。如果移植性对你来说很重要(例如说在写脚本),那么就查标准以及对应的手册。
回复 支持 反对

使用道具 举报

发表于 2007-5-30 23:19:02 | 显示全部楼层
还是喜欢 -a 这个。
回复 支持 反对

使用道具 举报

发表于 2007-6-1 06:48:46 | 显示全部楼层
在不确定的情况下,请使用-R或-a,不要使用-r。
-a = -d -p -R
使用-r的话,如果源目录中有类似/dev/cdrom之类的设备文件,不会复制该文件本身,而会把cdrom的内容(iso文件)复制过去。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表