Q:

How to Copy the Contents of a Folder to Another Folder from Terminal in Ubuntu

0

How to Copy the Contents of a Folder to Another Folder from Terminal in Ubuntu

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Use the cp Command

You can use the cp command to copy files locally from one directory to another.

For instance, if you want to copy the contents of the source folder to the destination folder in your current working directory, you can use the following command:

cp -a source/. destination/

The -a option copy files recursively, while preserving the file attributes such as timestamp. The period symbol (.) at end of the source path allows to copy all files and folders, including hidden ones.

For example, if your current working directory is /var/www and you want to copy the contents of the assets folder to backup folder, you can simply use the command:

cp -a assets/. backup/

Alternatively, you can provide absolute path like this:

cp -a /var/www/assets/. /var/www/backup/

Both commands will have the same effect, because current working directory doesn't matter when you use absolute path. Any path that starts with a forward slash / is an absolute path.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Ubuntu / Linux Frequently Asked Questions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
How to Install Updates Via Command Line on Ubuntu... >>
<< How to Rename a Directory Via Command Line in Ubun...