Copy Directory In Linux-Recursive Copy In Linux

Copy Directory In Linux-Recursive Copy In Linux

Copy command can't create directories or folders, so if you are trying to copy files or directories to destination directories, you must have destination directory before copying.

recursive copy in linux 

Recursive Copy:

Copy command can't copy the directory into other directories.

recursive folder copy in linux

If you try to copy the files and directories to another directory it will skip the directories but it will copy the files to the destination directory. So if you want to copy directories and files inside that directory to another directory we use recursive copy.

With recursive copy, we can copy files and directories to other directories. but a recursive copy also can't create a destination directory, only it will copy the files and directories to the destination directory.

for recursive copy, we use cp -r command.

syntax:

Copying Directory  In Linux:

cp –r  <dir1> <dir2>

it will copy the dir1 and its files to the dir2

copying all files and directories to the destination directory

cp –r /fath/to/the/files/* /path/to/destination/<dir2>

it will copy all files and folders to the destination directory.

1 Response

  1. Oli says:

    Pro tip – if you’re doing a large copy and want to be updated on it’s progress, use the -v ‘verbose’ flag to see the copy progression. E.g. –

    cp –rv /path/to/the/files/* /path/to/destination/<dir2>

Leave a Reply

Your email address will not be published. Required fields are marked *