You can copy the content of a folder
/source to another existing folder
/dest with the command
cp -a /source/. /dest/
-a option is an improved recursive option, that preserve all file attributes, and also preserve symlinks.
. at end of the source path is a specific
cp syntax that allow to copy all files and folders, included hidden ones.
An alternate is
rsync -a source/ destination
The advantages of
- 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.
Lets say you have a folder called folder1 in your
~, inside folder1 is 1 file called file1 and 2 folders called sub1 and sub2 each with other files and folders inside them.
To copy all the contents of
~/new_folder1 you would use
cp -r ~/folder1/. ~/new_folder1
new_folder1 would then contain all the files and folders from
cp is the command to copy using a terminal,
-r makes it recursively (so, current directory + further directories inside current)
~/folder1 is the origin folder,
~/new_folder1 is the destination folder for the files/folders inside the origin.