How to copy all of the files from one directory to another

I want to copy all of the files from a subdirectory into another directory without copying the original folder. In a terminal I would just do this:

cp -r dir1/* dir2

DO we have better way of doing it?
Asked on July 14, 2020 in Linux.
Add Comment
1 Answer(s)

An alternate is rsync

rsync -r source/ destination

The advantages of rsync are:

  1. After the initial sync, it will then copy only the files that have changed.
  2. You can use it over a network, convenient for files in $HOME, especially config files.


Use rsync command line instead in different way

rsync -auv dir1/ dir2/

will synchronize recursively all files from the folder dir1 into the folder dir2, with permission etc.

man rsync

to get more explanation to know how to use this comand line.


Answered on July 14, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.