cp:检测到循环:
关于 cp 的任何想法:检测到循环: Solaries 上的错误。我在将数据从一个目录复制到另一个目录时收到此消息。
Any idea about cp: cycle detected: Error on Solaries. I am getting this while I am copying data from one directory to the another directory.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当进行递归复制时,循环就是访问同一个“文件”两次。这可能是由于以循环方式设置链接造成的。例如,如果您创建目录
level1
:然后将其下的文件符号链接到该目录:
您基本上会得到循环引用。这意味着您可以:
随心所欲,永远不要离开
level1
目录。这会给递归复制带来问题,因为它实际上是无限循环。您可以使用 cp -rH 或 cp -rP (我认为在 Solaris 10 及更高版本上)不遵循符号链接。
具体来说,您可能会对以下三个标志感兴趣:
-H
:如果 source_file 操作数是符号链接,则 cp 复制由 source_file 操作数的符号链接引用的文件。遍历文件层次结构期间遇到的所有其他符号链接都将被保留。这意味着如果您指定为源的文件/目录是链接,它将复制该链接的目标。不会遵循该源下面的所有符号链接。-L
:复制符号链接引用的文件。不会保留遍历文件层次结构期间遇到的符号链接。这将跟随源下的所有符号链接。-P
:复制符号链接。遍历文件层次结构期间遇到的符号链接将被保留。我认为这与-H
相同,但也保留特定源的符号链接。A cycle, when doing a recursive copy, is visiting the same "file" twice. This can be caused by links being set up in a circular manner. For example, if you make the directory
level1
:then symbolically link a file under there to that directory:
you basically end up with a circular reference. That means you can do:
to your heart's content and never leave the
level1
directory. This causes problems for a recursive copy since it would effective be an infinite loop.You can use
cp -rH
orcp -rP
(on Solaris 10 and above, I think) to not follow the symlinks.Specifically, there are three flags you may be interested in:
-H
: If the source_file operand is a symbolic link, then cp copies the file referenced by the symbolic link for the source_file operand. All other symbolic links encountered during traversal of a file hierarchy are preserved. This means that if the file/directory you specify as the source is a link, it will copy the target of that link. All symbolic links underneath that source will not be followed.-L
: Copies files referenced by symbolic links. Symbolic links encountered during traversal of a file hierarchy are not preserved. This will follow all symbolic links under the source.-P
: Copies symbolic links. Symbolic links encountered during traversal of a file hierarchy are preserved. I think this is identical to-H
but also preserves the symbolic link for the specific source.尝试使用 cp 命令,如下所示:
Try using
cp
command as below: