Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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.

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

add the slash, it copies the contents of the directory

share|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

 
discard

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.