Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

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

I am trying to copy the contents of a folder to another folder in a different directory using terminal.

Would somebody be able to provide me an example of the command line syntax required to achieve this?
by

2 Answers

akshay1995
copy the content of a folder /source to another existing folder /dest with the command

cp -a /source/. /dest/

The -a option is an improved recursive option, that preserve all file attributes, and also preserve symlinks.

The . at end of the source path is a specific cp syntax that allow to copy all files and folders, included hidden ones.
RoliMishra
An alternate is rsync:

rsync -a source/ destination

The advantages of rsync are:

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

Login / Signup to Answer the Question.