bash 如何在bash中递归复制所有目录和文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8055501/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to copy in bash all directory and files recursive?
提问by user710818
I have script:
我有脚本:
find ./SourceFolder/ -maxdepth 4 -exec cp -R '{}' ./DestFolder/ \;
SourceDir
contains also sub-folders.
SourceDir
还包含子文件夹。
Problem that in DestFolder
not only all tree, but in up level all another levels and files.
问题不仅在DestFolder
所有树中,而且在所有其他级别和文件中。
How to fix ?
怎么修 ?
回答by lanzz
cp -r ./SourceFolder ./DestFolder
回答by user3708054
code for a simple copy.
简单复制的代码。
cp -r ./SourceFolder ./DestFolder
code for a copy with success result
复制成功的代码
cp -rv ./SourceFolder ./DestFolder
code for Forcefully if source contains any readonly file it will also copy
如果源包含任何只读文件,它也会复制 Forcefully 的代码
cp -rf ./SourceFolder ./DestFolder
for details help
详情帮助
cp --help