Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to copy my files but convert the symbolic links to hard links (ie. the actual file). How can I do this?

Here's my code (that isn't working):

cp -RL ${FROM_DIR} ${TO_DIR}

Note: this is for Xcode purposes - symlinks are not allowed in a build.



The issue is the way I remove the files first - it isn't removing existing symlinks.

rm -RLf "${FROM_DIR}/*"
share|improve this question

migrated from Nov 2 '12 at 7:36

This question came from our site for professional and enthusiast programmers.

up vote 2 down vote accepted

Not sure about UNIX cp implemebntation, but GNU cp by default is not preserving symlinks. And hard links are not the same thing as files. By default cp creates files/dirs from symlinks. Probably you don't need -L option for your purposes. If you really need this that you can use --no-preserve=links option.

Refer to man cp:

          preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links, xattr, all

          don't preserve the specified attributes
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.