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

user2080656 picture user2080656 · Feb 17, 2013 · Viewed 2.5M times · Source

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.

Answer

Pierre Salagnac picture Pierre Salagnac · Feb 17, 2013

The option you're looking for is -R.

cp -R path_to_source path_to_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.
  • Note the nuances with adding the trailing / as per @muni764's comment.