2

I am using a script to copy directories to a specified location. When I run cp -r ~/.ipython ~/some/path/.ipython the .ipython dir is copied as expected to the specified location. But when I run this command again ~/some/path/.ipython/.ipython is created.

I understand that this is recursive, but what command copies a dir while for subsequent calls of that command prevent a dir is recursively created inside that same dir?

1

Yes, as you've noticed, nothing prevent the cp command to create a new .ipython dir inside every other .ipython dir.

If you are using it in a script which you run repeatedly, the best approach to avoid the problem is not to use cp but rsync:

rsync -vua ~/.ipython/ ~/some/path/.ipython/

NB, the trailing / at the end of path is significant for rsync. If you are trying it out, don't forget to add that.

EDIT: Kruug's answer should be working as well, but rsync will yield better performance, especially when you are doing it repeatedly.

|improve this answer|||||
2
cp -r ~/.ipython/ ~/some/path/.ipython

add the slash, it copies the contents of the directory

|improve this answer|||||
  • 2
    Could you also do cp -r ~/.ipython ~/some/path/? – Kruug May 22 '13 at 18:47
  • Could you make a separate answer of this Kruug? – Bentley4 May 22 '13 at 19:15
  • @Rich Homolka : Running that command repeatedly still creates a new .ipython dir inside every other .ipython dir. – Bentley4 May 22 '13 at 19:19
  • why are you running the command repeatedly? – MattDMo May 22 '13 at 19:23
  • @MattDMo Because I'm using it in a script which I run repeatedly. – Bentley4 May 22 '13 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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