How to copy all files in the entire directory under Linux

Source: Internet
Author: User
Category: Linux using 2014-01-14 13:38 1449 people read reviews (0) favorite reports How do I copy a directory under Linux? It seems to be a more satisfactory problem.
For example, to copy/home/usera to/mnt/temp, the first thing I think about is


Cp-r/home/usera/*/mnt/temp


However, there is a problem, the hidden files under the/home/usera will not be copied, the sub-directory of hidden files will be.


What is the right way to do that? Some people say that with the-a option, someone says to use Find to add a pipeline.
In fact, not so complicated, Google, after learning a trick. It turns out only with "." The current directory instead of "*" just fine.


Cp-r/home/usera/. /mnt/temp


# # Update 2013/06/11
If there are already files in '/mnt/temp ', you just want to copy the new files under '/home/usera/', but do not want to overwrite the existing files in '/mnt/temp '? Sort of like merging two directories, right.


To deal with this situation ' CP ' has an option of '-n,–no-clobber ', which is to not overwrite existing files. It should be pretty useful, too.

from:http://www.leonzhang.com/2010/02/03/how_to_copy_folder_in_linux/

Note: Use the-a option to copy hidden files.

How to copy all files in the entire directory under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.