Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
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.
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).
Required, but never shown
5 years, 6 months ago