How to copy all files in a folder to another folder in Linux system?

        To copy or copy files in the Linux system, we can use the cp or copy command, but how to copy all the files in one folder to another folder? 

        We know that the function of the copy and cp commands is to copy the given file or directory to another file or directory. Syntax: cp [options] source file or directory destination file or directory

1. For example, create two subfolders, test1 and test2, in the /TEST directory. Assume that the test01 file under the source file test1 is copied, and the target directory is test2. 

        Can be used directly: cp /TEST/test1/test01 /TEST/test2



2. For example, create two subfolders, test1 and test2, in the /TEST directory. Suppose the source file test1 folder is copied and the target directory is test2. 

        Use directly: cp -r /TEST/test1 /TEST/test2



3. But to copy all the files in one folder to another folder, you should use cp -r /TEST/test1/. /TEST/test2 to copy the folders and files in test1 to test2. Of course, you can also use cp -r /TEST/test1/* /TEST/test2, the effect is exactly the same. 


Article source: http://www.jb51.net/LINUXjishu/336570.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326633143&siteId=291194637