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.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
level1directory. This causes problems for a recursive copy since it would effective be an infinite loop.You can use
cp -rHorcp -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-Hbut also preserves the symbolic link for the specific source.