homepage Welcome to WebmasterWorld Guest from 204.236.254.124
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
A way to copy .htaccess files?
Philosopher




msg:909959
 3:39 pm on Jun 8, 2006 (gmt 0)

Well let me start by saying I don't do much command line work with *nix systems so I'm sure I'm missing something simple.

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

 

brakthepoet




msg:909960
 5:53 pm on Jun 8, 2006 (gmt 0)

The -R option should have copied the .htaccess file. Are you sure it's not there? Try typing

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.

Philosopher




msg:909961
 1:33 am on Jun 9, 2006 (gmt 0)

no it's definitely not there.

I would have thought the -R option would have copied it as well, but it isn't for some reason.

if use

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?

brakthepoet




msg:909962
 2:31 am on Jun 9, 2006 (gmt 0)

Are you copying into an already existing directory?

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.

Philosopher




msg:909963
 3:26 am on Jun 9, 2006 (gmt 0)

Yeah, the issue is I'm basically copying the setup for one domain into an addon domains folder.

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.

wmuser




msg:909964
 10:48 pm on Jun 9, 2006 (gmt 0)

Thats wired,tro to CP once again with -R option

brakthepoet




msg:909965
 1:20 pm on Jun 12, 2006 (gmt 0)

Whoo-hoo! I asked around and got the answer on another *nix oriented board.

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved