How to copy in bash the entire directory and files recursively?

I have a script:

find ./SourceFoler/ -maxdepth 4 -exec cp -R '{}' ./DestFolder/ \; 

SourceDir also contains subfolders.

The problem is that in DestFolder not only the entire tree, but also the level above all other levels and files. How to fix? Thank.

+64
bash copy folder
Nov 08 2018-11-18T00:
source share
2 answers
 cp -r ./SourceFolder ./DestFolder 
+134
Nov 08 '11 at 18:45
source share

for a simple copy.

 cp -r ./SourceFolder ./DestFolder 

code for copy with success

 cp -rv ./SourceFolder ./DestFolder 

code to force, if the source contains any readonly file, it will also copy

 cp -rf ./SourceFolder ./DestFolder 

for more information

 cp --help 
+29
Jun 18 '14 at 5:45
source share



All Articles