How to cp files, including hidden, to an existing directory?
Posted: Sun Jun 11, 2006 5:48 pm
Here's one that's been a puzzler for me. At the command line, I would like to recursively copy files and directories to an existing directory, along with any hidden files within those directories. I know that cp can copy files recursively with -R, and preserve their permissions, etc, with -p, but I haven't been able to get the desired results.
The following
cp -Rp /pathtodirectory/old/ /pathtodirectory/new/
gets me what I want, unless /pathtodirectory/new/ already exists. If it exists, I'll end up with /pathtodirectory/new/old/
And this
cp -Rp /pathtodirectory/old/* /pathtodirectory/new/
copies everything except hidden files.
I'm totally stumped at this point. Any pointers in the right direction would be appreciated.
The following
cp -Rp /pathtodirectory/old/ /pathtodirectory/new/
gets me what I want, unless /pathtodirectory/new/ already exists. If it exists, I'll end up with /pathtodirectory/new/old/
And this
cp -Rp /pathtodirectory/old/* /pathtodirectory/new/
copies everything except hidden files.
I'm totally stumped at this point. Any pointers in the right direction would be appreciated.