1

I am a bit embarassed that, as a long-time linux user, I don't have an answer to this:

+- root-dir
+- dest

If I run cp -r root-dir dest/, then the complete content of root-dir is copied to dest/, including hidden files.

However, the result is

+-root-dir
+-dest
+----+ root-dir

If I do this though: cp -r root-dir/* dest/, then indeed I have all the content of root-dir at the dest/ folder with desired hierarchy - but the hidden files are not copied.

How can I get an exact copy of root-dir into dest but not as a subfolder? I can't just remove dest and rename it later, because dest already has some content which should be kept (in fact these are all git folders).

In other words, I want to merge both directories including hidden files. I also tried rsync -a but that seems to also exclude hidden files.

phtm
  • 11
  • 1
  • 1
    Try [how-to-copy-a-folder-recursively-in-an-idempotent-way-using-cp](https://unix.stackexchange.com/questions/228597/how-to-copy-a-folder-recursively-in-an-idempotent-way-using-cp). In this case I think you want `cp -R root-dir/. dest` – rowboat Aug 01 '23 at 16:49
  • Ah indeed! @rowboat that was the one I needed. "copying recursively" was too broad of a search to actually find what I was looking for...I was sure I wasn't the first with this issue. Thank you! – phtm Aug 01 '23 at 17:04

0 Answers0