[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:
> 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:

Unfortuntly, Debian relies on GNU and GNU has changed the licence on the
docs to be incompatible with Debian.  Notice that the stub of a man
pages directs you to info cp, however info cp gives you cpio instead.
OOPS.

try:
$ mkdir backup
$ cp -r i* backup/

I don't see anything like --ignore in the man page.

Personally, for stuff like that I use mc.  If I'm writing a script, I'm
using Python anyway.

Doug.



Reply to: