Home How do I copy folder with files to another folder in Unix/Linux?
Reply: 3

How do I copy folder with files to another folder in Unix/Linux?

user2080656
1#
user2080656 Published in 2013-02-17 15:16:20Z

I am having some issues to copy a folder with files in that folder into another folder. Command cp -r doesn't copy files in the folder.

Denialos
2#
Denialos Reply to 2017-10-24 16:38:59Z

The option you're looking for is -R.

cp -R source destination/

If destination doesn't exist, it will be created.

-R means copy directories recursively. You can also use -r since it's case-insensitive.

Peter Mortensen
3#
Peter Mortensen Reply to 2017-01-14 17:02:08Z

Use:

$ cp -R SRCFOLDER DESTFOLDER/
Smi
4#
Smi Reply to 2015-03-04 17:18:20Z

You are looking for the cp command. You need to change directories so that you are outside of the directory you are trying to copy. If the directory you're copying is called dir1 and you want to copy it to your /home/Pictures folder:

cp -r dir1/ ~/Pictures/

Linux is case-sensitive and also needs the / after each directory to know that it isn't a file. ~ is a special character in the terminal that automatically evaluates to the current user's home directory. If you need to know what directory you are in, use the command pwd.

When you don't know how to use a Linux command, there is a manual page that you can refer to by typing

man [insert command here]

at a terminal prompt.

Also, to auto complete long file paths when typing in the terminal, you can hit Tab after you've started typing the path and you will either be presented with choices, or it will insert the remaining part of the path.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.352063 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO