Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unix - copy contents of one directory to another [closed]

Folder1/     -fileA.txt     -fileB.txt     -fileC.txt  > mkdir Folder2/  > [copy command] 

And now Folder2/ looks like:

Folder2/     -fileA.txt     -fileB.txt     -fileC.txt    

How to make this happen? I have tried cp -r Folder1/ Folder2/ but I ended up with:

Folder2/     Folder1/         -fileA.txt         -fileB.txt         -fileC.txt 

Which is close but not exactly what I wanted.

Thanks!

like image 701
JDS Avatar asked Oct 22 '12 21:10

JDS


People also ask

How do you copy the contents of a directory to another directory in Linux?

In order to copy a directory on Linux, you have to execute the “cp” command with the “-R” option for recursive and specify the source and destination directories to be copied. As an example, let's say that you want to copy the “/etc” directory into a backup folder named “/etc_backup”.

How do I copy all contents from one directory to another?

To copy multiple files with the “cp” command, navigate the terminal to the directory where files are saved and then run the “cp” command with the file names you want to copy and the destination path.

How can I copy the contents of a folder to another folder in a different directory using terminal?

Copy a Directory and Its Contents ( cp -r ) Similarly, you can copy an entire directory to another directory using cp -r followed by the directory name that you want to copy and the name of the directory to where you want to copy the directory (e.g. cp -r directory-name-1 directory-name-2 ).


1 Answers

Try this:

cp Folder1/* Folder2/ 
like image 130
Geoff Avatar answered Nov 08 '22 15:11

Geoff