I'm working with a CentOS server. I have a folder named test
located in /home/server/folder/test
. I need to copy the directory test
to /home/server/
. How can I do it?
Similarly, you can copy an entire directory to another directory using cp -r followed by the directory name that you want to copy and the name of the directory to where you want to copy the directory (e.g. cp -r directory-name-1 directory-name-2 ).
To copy files to the current directory, use the command “cp source .” . For example, to copy file2 to the current directory type “ cp /root/file2 . “ To copy Directories, use the command cp –r .
Consider using keyboard shortcuts.Press Ctrl + C to copy the files. Go to the folder into which you want to copy the files. Press Ctrl + V to paste in the files.
The cp command also copies entire directories into other directories if you specify the -r or -R flags. You can also copy special-device files using the -R flag. Specifying -R causes the special files to be re-created under the new path name.
cp -r /home/server/folder/test /home/server/
To copy all files, including hidden files use:
cp -r /home/server/folder/test/. /home/server/
As I understand, you want to recursively copy test directory into /home/server/
path...
This can be done as:
-cp -rf /home/server/folder/test/* /home/server/
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With