Linux CentOS:将目录复制到另一个目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14549967/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 18:49:34  来源:igfitidea点击:

CentOS: Copy directory to another directory

linuxcentoscopycp

提问by BaTmaN

I'm working with a CentOS server. I have a folder named testlocated in /home/server/folder/test. I need to copy the directory testto /home/server/. How can I do it?

我正在使用 CentOS 服务器。我有一个名为的文件夹test位于/home/server/folder/test. 我需要将目录复制test/home/server/. 我该怎么做?

采纳答案by James McLaughlin

cp -r /home/server/folder/test /home/server/

回答by Rajeshwari

As I understand, you want to recursively copy test directory into /home/server/path...

据我了解,您想递归地将测试目录复制到/home/server/路径中...

This can be done as:

这可以通过以下方式完成:

-cp -rf /home/server/folder/test/* /home/server/

Hope this helps

希望这可以帮助

回答by deltaag

To copy all files, including hidden files use:

要复制所有文件,包括隐藏文件,请使用:

cp -r /home/server/folder/test/. /home/server/

回答by Hiren Parghi

This works for me.

这对我有用。

cp -r /home/server/folder/test/. /home/server

回答by Hasan Barary

For copy directory use following command

对于复制目录使用以下命令

cp -r source    Destination

For example

例如

cp -r  /home/hasan   /opt 

For copy file use command without -r

对于复制文件使用不带 -r 的命令

cp   /home/file    /home/hasan/