Welcome to WebmasterWorld Guest from 18.104.22.168
Forum Moderators: bakedjake
I have a directory that I want to copy over to many other directories.
I am using the following command sequence
cp -rRp * path/to/targetdirectory
Everything is copied and all permissions are preserved except for the .htaccess file. Is there an option I'm missing that will force cp to copy the .htaccess file as well?
Thanks in advance
ls -a path/to/targetdirectory
Does the .htaccess file show up that way? The -a option means "do not hide entries starting with .", so thought it might be worth a try.
I would have thought the -R option would have copied it as well, but it isn't for some reason.
cp -rRp directory path/to/target
the htaccess file gets copied, but the original directory gets copied to the target directory as a subdirectory.
Any ideas anyone?
from man cp:
(Thus, if /a is a directory, then `cp -r /a /b' will copy /a to /b/a and /a/x to /b/a/x in case a directory /b existed already, but it will copy /a to /b and /a/x to /b/x if there was no /b beforehand, while it will fail in case there was an ordinary file /b.)
So, if you want to copy /pathtodirectory/original/ to /pathtodirectory/copy/, and /pathtodirectory/copy/ already exists, you're going to end up with /pathtodirectory/copy/original/
If you want the end result to be /pathtodirectory/copy/, with all of the files and directories under /original/ now under /copy/, /pathtodirectory/copy/ shouldn't exist before issuing the cp commnand.
Also, don't use the * as a wild card to copy the files, or else you won't get the hidden files.
cp -rRp /pathtodirectory/original/ /pathtodirectory/copy/
(where /pathtodirectory/copy/ does not previously exist)
Hopefully, someone far smarter and more knowledgeable than me will come along and show some method to recursively copy into an existing directory. I'm stumped.
so I have public_html/domainA and after setting up domain B I have the new folder.
I guess I could try either copying the files first and creating the directory before setting up the addon domain and also try setting up the addon domain, then deleting the folder and starting over.
Would definitely be nice if there was a way to copy the "." files to an existing directory. Everything else works perfectly.
cp -rRp /pathtodirectory/original/. /pathtodirectory/copy/
I tested it out on my laptop using "." instead of "*", and it copied unhidden and hidden files to an already existing directory. See if it works for you.