[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Copy ./ to subdirectory.



On Wed, Aug 29, 2007 at 01:16:50PM +0100, James Preece wrote:
> This is probably a simple question but I can't find the answer
> anywhere and my friend Google won't search for ./ and 'copy' brings up
> all sorts.
> 
> Basically, I've got a folder containing various files for a website
> (for simplicity lets say it's this):
> 
> /mydirectory/index.html
> /mydirectory/images/image.gif
> 
> I want to make a backup so in the /mydirectory/ folder I do:
> 
> cp -r ./ backup
> 
> I wanted his to result in:
> 
> /mydirectory/index.html
> /mydirectory/images/image.gif
> /mydirectory/backup/index.html
> /mydirectory/backup/images/image.gif
> 
> Does that make sense? The error I get is:
> 
> cp: cannot copy a directory, `./', into itself, `backup'
> 
> Is there a way to have cp ignore the newly created directory? Something like:
> 
> cp -r ./ backup --ignore=backup

I usually do:

cp -a ./* ./.* backup/

You'll get an error when it tries to copy backup into itself, but
everything else will be copied fine.

	Ben

Attachment: signature.asc
Description: Digital signature


Reply to: