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.

How can I merge two folders with the same or different names with subdirectories, using shell script or terminal. Also, if there is a file with the same name, then it should skip.

share|improve this question
5  
What operating system are you on? Is there anything you've already tried? –  slhck May 20 '13 at 13:38
    
I am using Ubuntu. I want to merge using shell script or through terminal. –  sonu May 20 '13 at 15:37
add comment

1 Answer

To merge "dir2" into "dir1," I would expect the following to do what you want:

cp -nr dir2/* dir1/

The -r switch means copy recursively, and the -n switch means don't overwrite existing files (i.e., skip files with the same name).

share|improve this answer
add comment

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.